//新建字符串
NSString *text =@"这个是测试数据";
//计算文本文字size
CGSize size = [text sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:18.0f]}];
//获取宽高
CGSize statuseStrSize = CGSizeMake(ceilf(size.width), ceilf(size.height));
//打印宽高
NSLog(@"%@_width:%f_height:%f",NSStringFromCGSize(statuseStrSize),size.width,size.height);
网友评论