用到了,记录下
NSArray * labelArray = @[@"天苍苍",@"明日依山尽",@"老夫聊发少年狂",@"左牵黄右擒苍锦帽貂裘哈哈哈"];
for (int i = 0; i < labelArray.count; i++) {
UILabel *label = [UILabel new];
label.font = [UIFont systemFontOfSize:11];
label.text = labelArray[i];
[self.view addSubview:label];
CGSize size = [labelArray[i] sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:11.0f]}];
NSLog(@"==第%d个===%f===%f",i,size.width,size.height);
}
控制台Log
没换行高度计算一样的
网友评论