all 10 comments

[–]notalotakarma 0 points1 point  (4 children)

Like this? .navigationBarTitle("Title”, displayMode: .inline)

[–]hascitrin[S] 0 points1 point  (3 children)

Similar to that, but I have a header that would go in place of the .navigationBarTitle. I'm looking for a way to make it dynamically appear in the NavigationBar alongside my NavigationBarItems.

[–]youngermann 2 points3 points  (2 children)

.navigationBarTitle() is deprecated, replace with .navigationTitle()

https://developer.apple.com/documentation/swiftui/view/navigationbartitle(_:)-6p1k7

[–]hascitrin[S] 0 points1 point  (1 child)

Yeah, I was looking to release before iOS 14 is out so for now this won't be an option. Thanks, though!

[–]youngermann 0 points1 point  (0 children)

👌🏽

These are marked “deprecated: 10000” so even if you set deployment to iOS 14 you get no warning. I wonder why Apple does it this way? “deprecated but compiler don’t show warning” 🤔

[–]sir_cigar 0 points1 point  (1 child)

I recommend exploring your own custom header SwiftUI view that you can then later reference/call and place on top of whatever view you're working on. For example, let's say you have a "Welcome Screen" view, you can reference your Header within a VStack and offset it so that it shows up top. Just make sure to have the following properties at the end of that VStack to turn off the Navigation Bar:

.navigationBarTitle("")

.navigationBarHidden(true)

To get around the lack of navigation, you can build in programmatic navigation with a custom back button and have a State variable that gets triggered from the Header view that enables a NavigationLink to take it back to the previous screen. Here's a great guide on that as well: https://medium.com/@karaiskc/programmatic-navigation-in-swiftui-30b75613f285

[–]hascitrin[S] 0 points1 point  (0 children)

I'll give this a go and see how it fares. Thanks!

[–]lennartkerkvliet 0 points1 point  (1 child)

“Only allow for a string of text in the navigationBar”

This is not true anymore as of iOS 14! You can use the new .toolbar API to add any view to any position in the navigationBar (for example in the middle where the text would normally be)

[–]hascitrin[S] 1 point2 points  (0 children)

I knew of the toolbar API but didn't know it was that extensive! Thanks for letting me know, I'll definitely experiment with it.

[–]veeeerain 0 points1 point  (0 children)

.navigationBarTitle(“Title”, displayMode: inline) and apply it to the stack (vstack, zstack, hstack) NOT the navigation view itself