Skip to content

Instantly share code, notes, and snippets.

@Tunous
Created November 12, 2024 17:13
Show Gist options
  • Save Tunous/53d29c367deb51cb0f7dff3999da3626 to your computer and use it in GitHub Desktop.
Save Tunous/53d29c367deb51cb0f7dff3999da3626 to your computer and use it in GitHub Desktop.
Weird TabView in NavigationStack toolbar behavior
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
TabView {
List {
Text("Content")
}
}
.ignoresSafeArea(edges: .vertical)
.navigationTitle("Title")
.tabViewStyle(.page)
// Without following line scrollable content behaves incorrectly
// Content appears behind toolbar and scrolling doesn't update visibility of toolbar background
.background(Representable())
}
}
}
struct Representable: UIViewRepresentable {
func makeUIView(context: Context) -> some UIView {
return UIView()
}
func updateUIView(_ uiView: UIViewType, context: Context) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment