/**
通过文字计算
@param str 文本
@param witdth 限制最大的宽度
@param textFont 文本的font
@return 返回的size
*/
- (CGSize)boundingRectWithStr:(NSString *)str width:(CGFloat )witdth Font:(CGFloat )textFont
{
NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:textFont]};
CGSize size = [str boundingRectWithSize:CGSizeMake(witdth, 0) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;
return size;
}
网友评论