I am trying to display names on a custom navigation title For long names it is truncating, How do I display the text in multiple lines for long names, Here is the code I used for custom titleView
nameLabel.font = UIFont(name: “Arial-Medium", size: 19)
nameLabel.textAlignment = .center
nameLabel.numberOfLines = 2
nameLabel.adjustsFontSizeToFitWidth = true
nameLabel.lineBreakMode = .byCharWrapping
self.navigationItem.titleView = nameLabel
You can really control this behaviour if the text is very very long. Depending on the font size, you might be able to show full text but that too if is not too long (does not exceeds height of navigation bar/label). However here are few things might want to change :
nameLabel.numberOfLines = 2
nameLabel.lineBreakMode = NSLineBreakMode.ByTruncatingTail
nameLabel.adjustsFontSizeToFitWidth = true
nameLabel.minimumScaleFactor = 0.4