Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created July 20, 2020 21:26
Show Gist options
  • Save sturdysturge/b5d6ceb59af052bfe2ca61ee75f6e729 to your computer and use it in GitHub Desktop.
Save sturdysturge/b5d6ceb59af052bfe2ca61ee75f6e729 to your computer and use it in GitHub Desktop.
import SwiftUI
#if os(iOS)
struct ContentView: View {
@State var barStyle = BarStyle.automatic
enum BarStyle: String, CaseIterable {
case automatic, inline, large
var style: NavigationBarItem.TitleDisplayMode {
switch self {
case .automatic:
return .automatic
case .inline:
return .inline
case .large:
return .large
}
}
}
var body: some View {
Group {
List {
Picker(selection: $barStyle, label: Text(".navigationBarTitleDisplayMode")) {
ForEach(BarStyle.allCases, id: \.self) {
barStyle in Text(barStyle.rawValue)
}
}.pickerStyle(SegmentedPickerStyle())
ForEach(0...50, id: \.self) { _ in
Text("Example list item")
}
}
.navigationTitle(".navigationTitle")
.navigationBarTitleDisplayMode(barStyle.style)
}
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment