Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make change UILabel text not trigger auto layout

Tags:

ios

autolayout

I have a view controller in storyboard, and combining UILabel and ui collection view together in the controller. However every time I change the UILabel text, it will trigger auto layout, which shows I got view will layout and view did layout events. I don't want changing text to trigger auto layout. But When I use self.XCategoryLabel.translatesAutoresizingMaskIntoConstraints = NO;

It does not work.

How can I make UILabel text changing not trigger auto layout? I do use auto layout in this controller, but I DONT want the label to trigger it.

like image 883
Wingzero Avatar asked Oct 29 '25 20:10

Wingzero


1 Answers

I add a view in Storyboard, and add constraint to it. Then I add the UILabel into this view by code, and NOT setting Label.translatesAutoresizingMaskIntoConstraints to NO.

Then It will not trigger viewDidLayout and viewWillLayout.

like image 53
Wingzero Avatar answered Oct 31 '25 09:10

Wingzero



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!