jeudi 30 juin 2016

Multiple lines of text in UILabel in iOS 9


I`m working on an iOS project but when I updated to iOS 9 I had some problem with multiline in UILabels. I'm using Autolayout.

Anybody knows how to do it in iOS 9 ?

I tried different ways such as:

textLabel.lineBreakMode = UILineBreakModeWordWrap;
textLabel.numberOfLines = 0;

(from other similar question) but it did not work.

This is my logic to show multilines:

IB config:

preferedMaxLayout

enter image description here

label config

I update this value programmatically:

  • (void)configureLabelsMaxLayoutWidth { [self.view layoutIfNeeded]; self.titleLabel.preferredMaxLayoutWidth =CGRectGetWidth(self.titleLabel.frame); }

I call this method on the viewWillAppear


Aucun commentaire:

Enregistrer un commentaire