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