Liquid Glass UIButton Tint(background) Color

22 hours ago 2
ARTICLE AD BOX

On SwiftUI, you could achieve a tinted glass button by creating a custom button style

struct SomeButtonPreview: View { var body: some View { ZStack { LinearGradient( colors: [ .red, .orange, .yellow, .green, .blue, .indigo, .purple ], startPoint: .topLeading, endPoint: .bottomTrailing ) .ignoresSafeArea() Button("Tap Me") { } .buttonStyle(SomeBtnStyle()) } } } struct SomeBtnStyle: ButtonStyle { @ViewBuilder func makeBody(configuration: Configuration) -> some View { configuration.label .padding() .glassEffect(.regular.interactive().tint(.green)) } }

Result:
SwiftUI result

Yet, when I did the same thing in a UIKit button, it didn't result in the same design:

private let centerButton: UIButton = { let button = UIButton() button.setTitle("Tap Me", for: .normal) button.translatesAutoresizingMaskIntoConstraints = false var configuration = UIButton.Configuration.glass() configuration.background.backgroundColor = .green button.configuration = configuration return button }()

UIKitResult

It's more like a solid color with glass animation. That is not what I expect from it. So, how do I assign colors to glass in UIKit - especially buttons? I have read the official docs and could not find any hint of it.

Read Entire Article