天天看点

根据文字,字号,宽度确定高度

-(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;
}

           

继续阅读