Currently, I have large titles enabled for the navigation bar with the following code in the viewdidLoad of the ViewController:
navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationItem.largeTitleDisplayMode = .automatic
let date = Date()
let formatter = DateFormatter()
formatter.dateFormat = "MMMM dd"
let result = formatter.string(from: date)
self.title = "This is a Test\n\(result)"
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()
How can I present a completely different title when the navigation bar is collapsed in a "normal state" where the bar is no longer large?