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?
Asked
Active
Viewed 4,326 times
1
-
2How is the title being set? Just don't set the title and there won't be one. – rmaddy Jan 09 '18 at 21:30
-
Change Color https://stackoverflow.com/a/621185/6822622 – AshvinGudaliya Jan 10 '18 at 08:21
-
remove back button title :- https://stackoverflow.com/a/23853712/6822622 – AshvinGudaliya Jan 10 '18 at 08:21
3 Answers
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
Michael Lin Liu
- 81
- 2
- 2