Question Details

No question body available.

Tags

swift swiftui uikit liquid-glass

Answers (1)

May 7, 2026 Score: 0 Rep: 569 Quality: Low Completeness: 80%

You can achieve a SwiftUI-like .glassEffect(.regular.interactive().tint(.green)) in UIKit using UIVisualEffectView with UIGlassEffect

UIGlassEffect supports interactive glass materials and tint colors, while UIVisualEffectView provides the actual rendering. In this example, the button is embedded inside the effect view and the container’s corner radius is updated dynamically to create a capsule shape.

Result (UIKit & interactive glass effect):
enter image description here

Code example:

import UIKit
import SnapKit

class ViewController: UIViewController {

private let buttonContainerView: UIVisualEffectView = { let effect = UIGlassEffect(style: .regular) effect.isInteractive = true effect.tintColor = .systemGreen

let view = UIVisualEffectView(effect: effect)

return view }()

private let button: UIButton = { let button = UIButton(type: .system) button.setTitle("Tap Me", for: .normal) button.setTitleColor(.label, for: .normal)

return button }()

override func viewDidLoad() { super.viewDidLoad()

view.addSubview(buttonContainerView) buttonContainerView.contentView.addSubview(button) buttonContainerView.snp.makeConstraints { $0.center.equalToSuperview() }

button.snp.makeConstraints { $0.horizontalEdges.equalToSuperview().inset(12) $0.directionalVerticalEdges.equalToSuperview().inset(4) } }

override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews()

buttonContainerView.layer.cornerRadius = buttonContainerView.bounds.height / 2 } }