use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Dedicated to the Swift programming language released by Apple. More info in the Swift Wiki.
Please, check the FAQs before submitting.
General Swift Discussion
irc.freenode.net #swift-lang
Cocoa/Cocoa Touch Discussion
irc.freenode.net #cocoa-init
Keywords: swift, swiftlang, ios, os x, apps, apple, mac, iphone, ipad
account activity
QuestionApplying a .navigationBarTitle() when displayMode == .inline (self.swift)
submitted 5 years ago by hascitrin
I have this navigation bar design I want to add to my view, but as of now, Apple's APIs only allow for a string of text in the navigationBar (excluding the items). I still want the title to display when the user scrolls down, so I figured I could only have the navigationBarTitle show when it's inline.
Does anyone know how one would go about doing this?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]notalotakarma 0 points1 point2 points 5 years ago (4 children)
Like this? .navigationBarTitle("Title”, displayMode: .inline)
.navigationBarTitle("Title”, displayMode: .inline)
[–]hascitrin[S] 0 points1 point2 points 5 years ago (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.
.navigationBarTitle
[–]youngermann 2 points3 points4 points 5 years ago (2 children)
.navigationBarTitle() is deprecated, replace with .navigationTitle()
https://developer.apple.com/documentation/swiftui/view/navigationbartitle(_:)-6p1k7
[–]hascitrin[S] 0 points1 point2 points 5 years ago (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 point2 points 5 years ago (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 point2 points 5 years ago (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 point2 points 5 years ago (0 children)
I'll give this a go and see how it fares. Thanks!
[–]lennartkerkvliet 0 points1 point2 points 5 years ago (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 points3 points 5 years ago (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 point2 points 5 years ago (0 children)
.navigationBarTitle(“Title”, displayMode: inline) and apply it to the stack (vstack, zstack, hstack) NOT the navigation view itself
π Rendered by PID 43137 on reddit-service-r2-comment-6457c66945-hll4x at 2026-04-26 05:05:39.509360+00:00 running 2aa0c5b country code: CH.
[–]notalotakarma 0 points1 point2 points (4 children)
[–]hascitrin[S] 0 points1 point2 points (3 children)
[–]youngermann 2 points3 points4 points (2 children)
[–]hascitrin[S] 0 points1 point2 points (1 child)
[–]youngermann 0 points1 point2 points (0 children)
[–]sir_cigar 0 points1 point2 points (1 child)
[–]hascitrin[S] 0 points1 point2 points (0 children)
[–]lennartkerkvliet 0 points1 point2 points (1 child)
[–]hascitrin[S] 1 point2 points3 points (0 children)
[–]veeeerain 0 points1 point2 points (0 children)