首页 > 其他 > 详细

boundingRectWithSize 的使用, 计算UILable高度, 包含Emoji及多属性string.

时间:2014-09-04 13:13:19      阅读:497      评论:0      收藏:0      [点我收藏+]

iOS的文字高度计算一直是个问题, 苹果也一直在改, 这几天看了一下 boundingRectWithSize 方法.

- (CGRect)boundingRectWithSize:(CGSize)size options:(NSStringDrawingOptions)options context:(NSStringDrawingContext *)context NS_AVAILABLE_IOS(6_0);

  

踩了几个坑后, 总算找到比较好的使用方法.

 

http://stackoverflow.com/questions/13621084/boundingrectwithsize-for-nsattributedstring-returning-wrong-size

使用时的注意事项:

1: NSAttributedString 的每个部分都要至少设置两个属性: 

NSFontAttributeName

NSForegroundColorAttributeName

 

2:

 

 

 

boundingRectWithSize 的使用, 计算UILable高度, 包含Emoji及多属性string.

原文:http://www.cnblogs.com/willbin/p/3955786.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!