上海古都建筑设计集团,上海办公室装修设计公司,上海装修公司高质量的内容分享社区,上海装修公司我们不是内容生产者,我们只是上海办公室装修设计公司内容的搬运工平台

IOS 计算富文本的高度方法

guduadmin86天前

 方式一:

NSMutableAttributedString *attStr = [NSMutableAttributedString new];
CGSize attSize = [attStr boundingRectWithSize:CGSizeMake(UIScreen.mainScreen.bounds.size.width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil].size;
CGFloat height = size.height;

NSMutableAttributedString *attStr = [NSMutableAttributedString new];

CGSize attSize = [attStr boundingRectWithSize:CGSizeMake(UIScreen.mainScreen.bounds.size.width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil].size;

CGFloat height = size.height;

方式二:

NSMutableAttributedString *attStr = [NSMutableAttributedString new];
CGFloat height = [label sizeThatFits:CGSizeMake(UIScreen.mainScreen.bounds.size.width, CGFLOAT_MAX)].height;

NSMutableAttributedString *attStr = [NSMutableAttributedString new];

CGFloat height = [label sizeThatFits:CGSizeMake(UIScreen.mainScreen.bounds.size.width, CGFLOAT_MAX)].height;

网友评论

搜索
最新文章
热门文章
热门标签