UILabel to automatic line break when line is too long
My UILabel can do a line break according to the current \n . But if the line itself is too long, it won't be able to automatically do a line break. Can I do more configurations to my UILabel to achieve that?
And I've already used:
aLabel.lineBreakMode = UILineBreakModeWordWrap;
aLabel.numberOfLines = 0;
[aLabel setFont:[UIFont fontWithName:@"MarkerFelt-Wide" size:24]];
aLabel.textAlignment = UITextAlignmentCenter;
CGRect labelFrame = aLabel.bounds;
labelFrame.size = [words siz开发者_如何学编程eWithFont:aLabel.font constrainedToSize:CGSizeMake(LABEL_WIDTH, 100000) lineBreakMode:aLabel.lineBreakMode];
aLabel.frame = CGRectMake(0, 0, aLabel.frame.size.width-10, labelFrame.size.height);
words is a NSString
Set Number of line as you want to set.
aLabel.numberOfLines = 2;
if you are having text in a paragraph and want to place it in a lable with differ lines no need to use UILineBreakModeWordWrap.. simply write one line code as in how many lines you want to place the text as
labobj.numberOfLines = 90;
精彩评论