UILabel * label = [[UILabel alloc] init]; NSString * text = @ "hellohellohellohellohellohellohellohellohellohellohellohellohello"; label. text = text; [label setNumberOfLines: 0]; UIFont * font = [UIFont fontWithName: @ "Arial" size: 14]; // set the font label. font = font; CGSize size = CGSizeMake (300,200 000000f); size = [text sizeWithFont: font constrainedToSize: size lineBreakMode: NSLineBreakByCharWrapping]; [label set Frame: CGRectMake (10, 0, size. width, size. height)]; [self. view addSubview: label]; lineBreakMode: sets the display mode when the label text is too long. Label. lineBreakMode = NSLineBreakByCharWrapping. Label. lineBreakMode = NSLineBreakByClipping; cut the content length that is the same as the text width, and delete the second half. Label. lineBreakMode = NSLineBreakByTruncatingHead; the text above is ...... To display the text at the end. Label. lineBreakMode = NSLineBreakByTruncatingMiddle; the content in the middle is ...... To display the text at the beginning and end. Label. lineBreakMode = NSLineBreakByTruncatingTail ...... To display the text content of the header. Label. lineBreakMode = NSLineBreakByWordWrapping; displayed in the unit of words. The latter part is omitted and not displayed. Http://www.xue5.com/Mobile/iOS/673562.html this is the code on the Internet and can run normally. However, there is still a problem, that is, the label is dynamically generated here. If a dragged label in the view is connected to a corresponding attribute in the controller, the setFrame of this label is always invalid. In this case, you can click "size inspector", find the height equals in constraints, click the gear pattern behind it, and select and edit, set the value of Priority to a smaller value in height constraints.