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: