Skip to content

Instantly share code, notes, and snippets.

@ryanlintott
Created July 23, 2023 02:26
Show Gist options
  • Save ryanlintott/3a96fde5383199bb6008e110531b08c9 to your computer and use it in GitHub Desktop.
Save ryanlintott/3a96fde5383199bb6008e110531b08c9 to your computer and use it in GitHub Desktop.
A SwiftUI NavigationStack with a custom background color and no line below the title.
struct NavigationStackWithoutLine: View {
let backgroundColor = Color.green
var body: some View {
NavigationStack {
ScrollView {
Text("Hello, world!")
.frame(maxWidth: .infinity)
.foregroundColor(.white)
}
.navigationTitle("Hello")
.navigationBarTitleDisplayMode(.large)
.toolbarColorScheme(.light, for: .navigationBar)
.toolbarBackground(.hidden, for: .navigationBar)
.background { backgroundColor.ignoresSafeArea() }
.overlay(alignment: .top) {
backgroundColor.alignmentGuide(.top) { $0[.bottom] }
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment