iOS获取字符串高度
2016-03-07 14:54
393 查看
/** @method 获取指定宽度width的字符串在UITextView上的高度 @param textView 待计算的UITextView @param Width 限制字符串显示区域的宽度 @result float 返回的高度 */ - (float) heightForString:(UITextView *)textView andWidth:(float)width{ CGSize sizeToFit = [textView sizeThatFits:CGSizeMake(width, MAXFLOAT)]; return sizeToFit.height; }
使用方法
UITextView * txtView = [[UITextView alloc] init]; txtView.text = noticeStr; float strHeight = [self heightForString:txtView andWidth:ScalingWidth(280.0)];
注:以前使用的方法总有不准确的情况,这个一试一个准,��
相关文章推荐
- iOS 设备定位功能可用的判断
- IOS 获取设备机型 系统版本 应用版本
- iOS pod install update 慢!!!
- IOS的变量修饰词@public 、@protected、@package、@private,简称 4P
- IOS学习 scrollView的基本属性
- iOS7 tableview separatorInset cell分割线左对齐
- 【Xamarin挖墙脚系列:IOS-关于手机支持的屏幕方向】
- 【Xamarin挖墙脚系列:Xamarin.IOS机制原理剖析】
- iOS开发有关Core Animation的介绍
- iOS-触摸事件
- iOS多线程
- 【Xamarin挖墙脚系列:Xamarin.IOS的程序的结构】
- IOS中对Url进行编码和解码
- 【Xamarin 挖墙脚系列:IOS 开发界面的3种方式】
- ios googlemaps 开发 设置地图可见所有大头针
- iOS打包,证书配置等
- IOS常用第三方库
- iphone ios 和pc间通过wifi通讯,连接
- iOS项目统计代码行数
- iOS 预编译命令小记