calculateLabelHeightWithString

calculateLabelHeightWithString


//计算cell label 等行高

- (NSInteger)calculateLabelHeightWithString:(NSString *)string
{
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
paraStyle.lineSpacing = 3;
CGSize size = [string boundingRectWithSize:CGSizeMake(_screenWidth-40, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:13], NSParagraphStyleAttributeName : paraStyle }
context:nil].size;
return (NSInteger)(ceilf(size.height));
}







Loading Disqus comments...
Table of Contents