天天看點

根據文字,字号,寬度确定高度

-(CGFloat)heightWithWidth:(CGFloat)width andString:(NSString *)str andFontSize:(int)fontSize{
    CGSize titleSize = [str boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]} context:nil].size;
    return titleSize.height;
}

           

繼續閱讀