UILabel * label = [[UILabel alloc] initWithFrame: CGRectMake (,)]; // sets the number of automatic lines and line breaks. If it is 0, it indicates no limit [label setNumberOfLines: 0]; label. lineBreakMode = NSLineBreakByWordWrapping; // use the NSString * strTest = @ line feed method to test the link in a hybrid manner! Just test, good luck !! See if this works. "; UIFont * font = [UIFont fontWithName: @" Arial "size: 12]; label. font = font; CGSize size = CGSizeMake (LableWight, CGFLOAT_MAX); // LableWight label width, fixed
// Calculate the actual frame size and change the frame size of the label to the actual size.
CGSize labelsize = [strTest sizeWithFont: font constrainedToSize: size lineBreakMode: label. lineBreakMode];
Label. frame = CGRectMake (0, 0, labelsize. width, labelsize. height); label. text = strTest; [self. view addSubview: label];