0
我有一个应用程序,标签和大文本。我试图适应标签的高度,文字是这样的:UILabel适合文本
UILabel *description = [[UILabel alloc] initWithFrame:CGRectMake(20, sizeInSpik, 275, 0)];
description.text = spik.text;
description.adjustsFontSizeToFitWidth = NO;
description.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[description setFont:[UIFont fontWithName:@"Helvetica Neu" size:13]];
description.textColor = [UIColor blackColor];
description.lineBreakMode = UILineBreakModeWordWrap;
description.numberOfLines = 0;
[description sizeToFit];
// Set the height
CGSize maximumLabelSize1 = CGSizeMake(270,9999);
CGSize titleSize1 = [description.text sizeWithFont:description.font constrainedToSize:maximumLabelSize1 lineBreakMode:description.lineBreakMode];
//Adjust the label the the new height
CGRect newFrame1 = description.frame;
newFrame1.size.height = titleSize1.height;
description.frame = newFrame1;
description.backgroundColor = [UIColor greenColor];
但是,当我实现这个代码的结果是这样的:
绿颜色的UILabel背景。
问题是什么?
PS此外字体大小isnt 13.为什么?
你检查了titleSize1.height是否它不是9999? – Khal 2012-03-13 15:02:04