0
点赞
收藏
分享

微信扫一扫

ios7 UILabel 高度 sizeWithFont被摒弃

郝春妮 2022-08-08 阅读 36

//根据要显示的text计算label高度
- (CGFloat)contentCellHeightWithText:(NSString*)text
{
NSInteger ch;
UIFont *font = [UIFontfontWithName:@"Arial"size:11];//11 一定要跟label的显示字体大小一致
//设置字体
CGSize size = CGSizeMake(300, 20000.0f);//注:这个宽:300 是你要显示的宽度既固定的宽度,高度可以依照自己的需求而定
if (SystemVersion_7x)//IOS 7.0 以上
{
nil];
nil].size;
}
else
{
//ios7以上已经摒弃的这个方法
}
height;
return

}

举报

相关推荐

0 条评论