Categories
ios swift swift3 uinavigationbar xcode

Multiline Navigationbar Title

I am trying to set the title label in my navigation bar to allow multiple lines. I have custom navigation controller code that I am placing the multiline code into. I know that the code already there works, but my multiline part is not working.

let titleLabel = UILabel()
titleLabel.frame = CGRectMake(0, 0, self.navigationBar.frame.width, self.navigationBar.frame.height * 2)
titleLabel.numberOfLines = 0
titleLabel.lineBreakMode = .ByWordWrapping
navigationItem.titleView = titleLabel

But the text still runs off at the end. I’ve also tried putting this into the individual view controller itself, adding self.navigationController?. in front of navigationItem with the same results.

Is there something I’m missing in my code that would keep the title label from using multiple lines?