iOS 设置UILable字体,及计算长度和位置

    UILabel *lastLable = [[UILabel alloc] init];
    UIFont *font = [UIFont fontWithName:lastLable.font.fontName size:[UIFont labelFontSize]-3];
    lastLable.font = font;


/**
 *  获取指定字体的字符串的长度
 *
 *  @param str  字符串
 *  @param font 字符串的字体
 *
 *  @return 字符串的长度
 */
-(double)getWidthWithString:(NSString*)str font:(UIFont*)font{
    NSDictionary *dict = @{NSFontAttributeName:font};
    CGSize detailSize = [str sizeWithAttributes:dict];
    return detailSize.width;
}
原文地址:https://www.cnblogs.com/SimonGao/p/5050030.html