1

Perhaps it's my lacking google skills, but I can't seem to find the proper code to remove the title(s) on my navigation bar. Have searched here as well, but all I can find is removing backbutton text or changing color of title... Any ideas?

shallowThought
  • 18,342
  • 7
  • 61
  • 106
Joakim Sjöstedt
  • 618
  • 1
  • 7
  • 14

3 Answers3

3

You have probably set the title in Storyboard. Remove it in Storyboard or set the title to nil in viewDidLoad() of your UIViewController instance:

override func viewDidLoad() {
    super.viewDidLoad()
    self.title = nil
}
shallowThought
  • 18,342
  • 7
  • 61
  • 106
2

Programmatically set navigation bar title empty string in viewDidLoad() of your UIViewController() instance:

override func viewDidLoad() {
    super.viewDidLoad()

    self.navigationItem.title = ""
}
Emre Özdil
  • 381
  • 5
  • 11
1

The mechanism to remove the title in code is always like .remove().
In Swift5, we have titleView?.removeFromSuperview() to remove the title view and title?.removeAll() to remove the text in title:

//M: find your controller -> tabBarController -> navigationItem -> titleView/title -> remove
self.tabBarController?.navigationItem.titleView?.removeFromSuperview()
self.tabBarController?.navigationItem.title?.removeAll()
סטנלי גרונן
  • 2,849
  • 23
  • 46
  • 65