美文网首页
根据文字计算UILabel的宽高

根据文字计算UILabel的宽高

作者: 死靓仔 | 来源:发表于2016-10-08 16:26 被阅读29次

单行文字

CGSize size =[content sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}];

多行文字

CGSize size = [content boundingRectWithSize:CGSizeMake(kScreen_Width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size;

相关文章

网友评论

      本文标题:根据文字计算UILabel的宽高

      本文链接:https://www.haomeiwen.com/subject/raiuyttx.html