boundingRectWithSize 动态计算文字的高度
来源:互联网 发布:我欲封天蛇魅进阶数据 编辑:程序博客网 时间:2024/05/16 19:37
通过设置字符串的属性计算实际的面积
方法如下:
-(CGSize)sizeForString:(NSString *)string{
NSMutableAttributedString *attrStr =[[NSMutableAttributedString alloc]initWithString:string];
NSRange allRange = [string rangeOfString:string];
[attrStr addAttribute:NSFontAttributeName
value:[UIFont systemFontOfSize:16]
range:allRange];
NSStringDrawingOptions options = NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading;
CGSize textSize = [attrStr boundingRectWithSize:CGSizeMake(size_w, size_h)
options:options
context:nil].size;
return textSize;
}
0 0
- boundingRectWithSize 动态计算文字的高度
- UIKit-boundingRectWithSize计算多行UILabel的文字高度
- 动态计算文字的高度
- 使用boundingRectWithSize计算内容高度的坑
- 使用boundingRectWithSize计算内容高度的坑
- boundingRectWithSize 的使用,计算Label高度
- 使用boundingRectWithSize计算内容高度的
- boundingRectWithSize计算label 高度
- boundingRectWithSize计算高度不准确
- boundingRectWithSize计算高度不准确
- UILable的使用,文本高度的计算boundingRectWithSize
- boundingRectWithSize 7.0以后计算文本高度的方法
- IOS BUG记录 boundingRectWithSize计算内容宽度高度的问题
- iOS 使用 boundingRectWithSize: 计算 UILabel 高度错误的解决方案
- 计算文字的高度
- 根据Label的文字内容动态计算Label高度
- iOS中动态计算不同颜色、字体的文字高度
- - (CGRect)boundingRectWithSize: options: attributes:计算label高度
- js分页、表格
- 如何处理僵尸进程
- 第十六周项目2-用指针玩字符串(2-去掉空格)
- enum枚举的意义
- python异常处理(基础)
- boundingRectWithSize 动态计算文字的高度
- 用函数指针调用函数
- android 多选相册,照相,浏览删除
- 最没风险的尝试,微整入门先试玻尿酸!
- XSSer使用
- 微博与微信
- 解决sql server 安装需要一直重启问题
- WPF 只允许输入数字的文本框
- ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim()