.navigationBarTitle deprecation

A common pattern (for me at least) in iOS 13 was to set navigation bar titles on subviews:

Code Block swift
struct FlavorView: View {
let items = ["Chocolate", "Vanilla", "Strawberry", "Mint Chip",
"Pistachio"]
var body: some View {
NavigationView {
List(items, id: \.self) {
Text($0)
}
.navigationBarTitle(Text("Today's Flavors"))
}
}
}


According to the documentation, this is now deprecated (https://developer.apple.com/documentation/swiftui/group/navigationbartitle(_:)-w0qq )

I couldn't find any other documentation on what the recommended way to set the navigation bar title now is. Can anybody point me in the right direction?

Answered by Apple Designer in 615152022
Howdy!

.navigationBarTitle() has been deprecated and replaced by .navigationTitle() — which is available on all platforms. This makes it much easier to build up your hierarchy in a multi-platform way and have it work correctly on iOS, macOS, watchOS, and tvOS.
https://developer.apple.com/documentation/swiftui/vstack/navigationtitle(_:)-yfmf

If you need iOS-specific functionality like specifying whether to use the large title or inline navigation bar title options, those now live in the iOS-only .navigationBarTitleDisplayMode() modifier.
https://developer.apple.com/documentation/swiftui/stepper/navigationbartitledisplaymode(_:)

Additionally on macOS you can now specify a .navigationSubtitle()
https://developer.apple.com/documentation/swiftui/vstack/navigationsubtitle(_:)-1qkvj
Accepted Answer
Howdy!

.navigationBarTitle() has been deprecated and replaced by .navigationTitle() — which is available on all platforms. This makes it much easier to build up your hierarchy in a multi-platform way and have it work correctly on iOS, macOS, watchOS, and tvOS.
https://developer.apple.com/documentation/swiftui/vstack/navigationtitle(_:)-yfmf

If you need iOS-specific functionality like specifying whether to use the large title or inline navigation bar title options, those now live in the iOS-only .navigationBarTitleDisplayMode() modifier.
https://developer.apple.com/documentation/swiftui/stepper/navigationbartitledisplaymode(_:)

Additionally on macOS you can now specify a .navigationSubtitle()
https://developer.apple.com/documentation/swiftui/vstack/navigationsubtitle(_:)-1qkvj
Thank you, the new API makes a lot of sense. Have a good WWDC 😊
.navigationBarTitle deprecation
 
 
Q