首页 > 代码库 > iOS 7 计算字符串高度

iOS 7 计算字符串高度

- (float)width:(NSString *)str font:(UIFont *)font{    NSDictionary *attribute = @{NSFontAttributeName:font};        CGSize size = [str boundingRectWithSize:CGSizeMake(_bgView.frame.size.width - 2*MARGIN_TOP, CGFLOAT_MAX) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;    return size.height;}