UILabel AutoLayout Line-break version differences

Source: Internet
Author: User

A bug related to Uilabel was resolved today.

Performance for the system above iOS7, Uilabel can automatically wrap, multi-line display of the string, and on the iOS6 above will not automatically wrap, directly hit the ellipsis.

Under normal circumstances, NumberOfLines is set to 0,uilabel and will wrap automatically.

However, you need to set preferredmaxlayoutwidth,autolayout below the iOS6 to determine the position of the line, in order to correctly display the multi-line Uilabel

But how much is preferredmaxlayoutwidth set to be correct?

If you know an exact width of course is the best, then directly set it up,

However, if the width of the Uilabel is adaptive and uncertain, then the following code can be used to set the

-(void) layoutsubviews{    [Super layoutsubviews];    Self.label.preferredMaxLayoutWidth = Self.label.bounds.size.width;}



When the label is already displayed on the interface, the width is determined and can be set directly with the width as the maximum autolayout width. This is normal.

UILabel AutoLayout Line-break version differences

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.