iOS8 - (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size 的替代方法

时间:2023-02-01 08:33:57
 
NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
CGSize size = [label.text boundingRectWithSize:CGSizeMake(200, MAXFLOAT) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;