In the development of iOS, we often need to dynamically display the content of the text on the label, when the content on the label is more than one line, we need to implement line wrapping, so that the text can be divided into multiple lines to display. The following is an example of the implementation:
<span style= "FONT-SIZE:18PX;" >cgfloat UIScreen mainscreen]bounds].size.width;self.textlabel.frame = CGRectMake (view_width-10-105, 40) //label height is greater than font height Self.textLabel.font = [Uifont fontwithname:nil size:16]; [Self.textlabel setlinebreakmode:nslinebreakbywordwrapping]; Specify line break mode self.textLabel.numberOfLines = 0; Specify the number of rows for a label </span>
In the implementation of line wrapping, a problem is that when the height of the label is not large enough to implement line wrapping, the label still displays only one row, so when you set the label height, try to make the label height greater than the font height.
Implementation results:
iOS implements Uilabel line break