Created
March 1, 2026 20:10
-
-
Save VAndrJ/8eeee5e190d2b95fb5c1abcb0a380070 to your computer and use it in GitHub Desktop.
Liquid Glass TabBar issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct ContentView: View { | |
| var body: some View { | |
| TabView { | |
| FirstView() | |
| .tabItem { | |
| Text("First") | |
| } | |
| SecondView() | |
| .tabItem { | |
| Text("Second") | |
| } | |
| } | |
| } | |
| } | |
| struct FirstView: View { | |
| var body: some View { | |
| ZStack(alignment: .center) { | |
| exampleColor | |
| .ignoresSafeArea() | |
| // ScrollView {} // Uncomment this crutch to solve Liquid Glass TabBar problem | |
| GlassButton { | |
| } label: { | |
| Text("Test") | |
| } | |
| } | |
| } | |
| } | |
| struct SecondView: View { | |
| var body: some View { | |
| ZStack { | |
| exampleColor | |
| .ignoresSafeArea() | |
| GlassButton { | |
| } label: { | |
| Text("Test") | |
| } | |
| List(1...100, id: \.self) { i in | |
| Text("\(i)") | |
| .listRowBackground(Color.clear) | |
| } | |
| .listStyle(PlainListStyle()) | |
| } | |
| } | |
| } | |
| struct GlassButton<Label: View>: View { | |
| let action: () -> Void | |
| let label: () -> Label | |
| let size: CGSize | |
| init( | |
| size: CGSize = .init(width: 45, height: 45), | |
| action: @escaping () -> Void, | |
| @ViewBuilder label: @escaping () -> Label | |
| ) { | |
| self.action = action | |
| self.label = label | |
| self.size = size | |
| } | |
| var body: some View { | |
| Button(action: action) { | |
| label() | |
| } | |
| .buttonStyle(.plain) | |
| .frame(width: size.width, height: size.height) | |
| .glassEffect(.clear.interactive().tint(exampleColor)) | |
| } | |
| } | |
| let exampleColor = Color(UIColor(red: 0.17, green: 0.25, blue: 0.32, alpha: 1.00)) | |
| #Preview { | |
| ContentView() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment