Search code examples
swiftuinavigationbartitlebar

Update title for a custom navigation bar


I have a custom navigation bar that I have created from my Storyboard and dragged an IBOutlet to it, but I cant´t figure out how to change to title for it dynamically. My navigationBar does not have any title attribute on it.

Any ideas how to solve this?


Solution

  • On your custom navigationBar you have an attribute called topItem:

    The navigation item at the top of the navigation bar’s stack.

    Use it to change your title for your custom navigationBar like this:

    navigationBar.topItem?.title = "Some title"