Is it possible to have the new large titles for navigation bars in iOS 11 show multiple lines? The App Store app does this but I can't find anything in the current documentation to do this. The standard behavior just shows one line with ellipsis if it's too long.
Asked
Active
Viewed 4,470 times
17
-
did you get any solution for this ? – Jigar Thakkar Dec 20 '17 at 09:49
-
If it can help here's what I did a another thread : https://stackoverflow.com/a/50647001/631927 – Bejil Jun 04 '18 at 07:20
2 Answers
5
Add following code into viewWillAppear:
navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationItem.largeTitleDisplayMode = .automatic
self.title = "Hello big text, For navigation large style bar"
navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.black, NSAttributedStringKey.font : UIFont.preferredFont(forTextStyle: .largeTitle)]
var count = 0
for item in(self.navigationController?.navigationBar.subviews)! {
for sub in item.subviews{
if sub is UILabel{
if count == 1 {
break;
}
let titleLab :UILabel = sub as! UILabel
titleLab.numberOfLines = 0
titleLab.text = self.title
titleLab.lineBreakMode = .byWordWrapping
count = count + 1
}
}
}
self.navigationController?.navigationBar.layoutSubviews()
self.navigationController?.navigationBar.layoutIfNeeded()
Facing issue with back button will update soon..

Rahul_Chandnani
- 275
- 2
- 9
-
Any update for the back button issue? I can only get it to work in the viewdidappear, which only applies after the view is visible and thus looks blocky. – Coltuxumab Apr 27 '18 at 10:02
-
2maybe you can just use break where you've assigned the count. – tryKuldeepTanwar Jul 30 '18 at 07:20
-
4this does not work, the label goes multiline but nav bar does not increase its height @Rahul_Chandnani – Shahzaib Qureshi Nov 07 '18 at 05:07
-
1
There is a way to do this simply by using a non-public API. Use at your own risk:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
title = "Thunderbox Entertaiment"
navigationItem.enableMultilineTitle()
}
}
extension UINavigationItem {
func enableMultilineTitle() {
setValue(true, forKey: "__largeTitleTwoLineMode")
}
}

dronpopdev
- 797
- 10
- 13
-
private api may lead to unpredictable results like crashes and review rejection – Gargo Aug 11 '23 at 13:10