I can't seem to find the proper code to remove the title(s) on my navigation bar. Any ideas?
Asked
Active
Viewed 6,032 times
2
-
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
- 19,212
- 9
- 65
- 112
3
Programmatically set navigation bar title empty string in viewDidLoad()
of your UIViewController()
instance:
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = ""
}

Emre Ozdil
- 401
- 6
- 12
2
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,917
- 23
- 46
- 68

Michael Lin Liu
- 131
- 2
- 2