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

 

相关文章:

  • 2022-12-23
  • 2022-01-22
  • 2022-01-10
  • 2021-07-07
  • 2022-12-23
  • 2021-08-30
  • 2022-12-23
猜你喜欢
  • 2021-12-07
  • 2022-01-03
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2022-01-12
  • 2021-09-01
相关资源
相似解决方案