IOS implements UILabel line feed and iosuilabel line feed.

Source: Internet
Author: User

IOS implements UILabel line feed and iosuilabel line feed.

During iOS development, we often need to dynamically display the text content based on the label. When the content on the label exceeds one line, we need to implement line breaks so that the text can be displayed in multiple lines. The following is an example:

<Span style = "font-size: 18px;"> CGFloat UIScreen mainScreen] bounds]. size. width; self. textLabel. frame = CGRectMake (105, 20, view_width-10-105, 40); // The label height must be greater than the font height self. textLabel. font = [UIFont fontWithName: nil size: 16]; [self. textLabel setLineBreakMode: NSLineBreakByWordWrapping]; // specify the line feed mode self. textLabel. numberOfLines = 0; // specify the number of lines of the label </span>


In the process of implementing line feed, a problem occurs: When the label height is not large enough, the line feed cannot be implemented, and the label still displays only one line, therefore, when setting the label height, try to make the label height greater than the font height.


Effect:



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.