自从iOS7以后更新了计算方法
//定义字体
NSDictionary *attrs = @{NSFontAttributeName :[UIFont systemFontOfSize:14]};
//定义这个空间文字最大的宽度和高度,这里定义了可以无限宽和高
CGSize maxsizes=CGSizeMake(MAXFLOAT, MAXFLOAT);
UILabel *texts;
texts.text=@"haaaaaaaaa";
//textzise即为当前控件文字的所占宽高
CGSize textzise= [texts.text boundingRectWithSize:maxsizes options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
NSLog(@"%f--%f",textSize.width,textzise.height);
原文:http://www.cnblogs.com/yumian/p/5126362.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!