I’m trying to get the navigation title vertically aligned with the back button in a NavigationDetail view in SwiftUI. Here’s what this looks like currently:
Below’s my code for adding the Navigation Bar title to the view. How do I get it vertically aligned with the Back button?
var body: some View {
Text("My Detail View")
.navigationBarTitleDisplayMode(.inline)
VStack {
List {
ForEach(0..<layerSettings.count, id: .self) { each in
...
}
}
2
Answers
If you need to draw "My Detail View" on the same line that the Back button, try to do like this:
Since
navigationBarTitle(_:)
is Deprecated. UsenavigationTitle(_:)
together withnavigationBarTitleDisplayMode(_:)
in iOS 14.0+