In swiftui, how do i implement two buttons? such that one button uses regular glass and another uses liquid glass?

Asked on 2025-06-12

1 search

To implement two buttons in SwiftUI, where one uses regular glass and the other uses liquid glass, you can use the new button styles introduced in the WWDC 2025 session "Build a SwiftUI app with the new design." Here's a basic example of how you might set this up:

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack {
            // Regular Glass Button
            Button(action: {
                // Action for regular glass button
            }) {
                Text("Regular Glass Button")
            }
            .buttonStyle(GlassButtonStyle()) // Use the regular glass style

            // Liquid Glass Button
            Button(action: {
                // Action for liquid glass button
            }) {
                Text("Liquid Glass Button")
            }
            .buttonStyle(LiquidGlassButtonStyle()) // Use the liquid glass style
        }
    }
}

In this example, GlassButtonStyle and LiquidGlassButtonStyle are hypothetical styles based on the session's description. You would replace these with the actual styles provided by SwiftUI for glass and liquid glass effects.

For more detailed information on implementing these styles, you can refer to the session Build a SwiftUI app with the new design (17:57) where Liquid Glass effects are discussed.