sizeWithFont:constrainedToSize:转boundingRectWithSize:options:

转载自:   http://blog.sina.com.cn/s/blog_727bd1560101rde8.html

CGFloat width1=[(NSString *)ob1 sizeWithFont:[UIFont systemFontOfSize:16] constrainedToSize:CGSizeMake(1000, FONTHEIGHT)].width;

CGFloat width1=[(NSString *)ob1 boundingRectWithSize:CGSizeMake(1000, FONTHEIGHT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} context:nil].size.width;

boundingRectWithSize: CGSize 对应 constrainedToSize: CGSize
attributes:@{NSFontAttributeName: [ UIFont ] } 对应 sizeWithFont[ UIFont ]
options: NSStringDrawingUsesLineFragmentOrigin 默认照填
context: nil 默认照填


你可能感兴趣的:(sizeWithFont:constrainedToSize:转boundingRectWithSize:options:)