I have some code:
CGRect currentFrame = textLabel.frame;
CGSize max = CGSizeMake(textLabel.frame.size.width, 3000);
CGSize expected = [[textLabel text] sizeWithFont:textLabel.font constrainedToSize:max lineBreakMode:textLabel.lineBreakMode];
currentFrame.size.height = expected.height;
textLabel.frame = currentFrame;
expected.height = expected.height + 70;
[scrollView setContentSize:expected];
textLabel placed inside UIScrollView to display multiline text information.
In older version of application, without 4-inch screen support, everything was perfect. But now, unfortunately, resizing UILabel does not work.
Maybe, somebody can advice me, what should I change?
Thanks.
When using AutoLayout you should not update the frame property, instead modify the contraints on a view.
On the other hand, you could also let AutoLayout work for you. Make sure the numberOfLines
property of the label is set to 0 and the height constraint is of type Greater Than or Equal
(>=). This way the layout will update automatically after setting new text on a label.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With