首页 > 其他 > 详细

object-c sizeWithFont

时间:2015-02-03 16:33:53      阅读:189      评论:0      收藏:0      [点我收藏+]

 ********************************    IOS6 获取字符串size    ********************************

单行字符串:  CGSize size_width = [str_new sizeWithFont:[UIFont systemFontOfSize:20]];

多行字符串: CGSize labelSize = [self.textLabel.text sizeWithFont:[UIFont systemFontOfSize:14.0f]

                                       constrainedToSize:CGSizeMake(226.0f, MAXFLOAT)

                                           lineBreakMode:0];

 

********************************    IOS7 获取字符串size     ********************************

单行字符串: CGSize size_width = [str_new sizeWithAttributes: @{NSFontAttributeName:[UIFont systemFontOfSize:20]}];

多行字符串:CGSize labelSize = [self.textLabel.text boundingRectWithSize:CGSizeMake(226, MAXFLOAT) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size;

 

备注:

NSStringDrawingOptions参数

技术分享

 

 

object-c sizeWithFont

原文:http://www.cnblogs.com/madaha/p/4269963.html

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