iOS小demo之获取文字高度
来源:互联网 发布:python splinter 编辑:程序博客网 时间:2024/05/16 14:12
//本帖为自用贴,不喜勿喷
-(float) heightForString:(NSString *)value fontSize:(float)fontSize andWidth:(float)width
{
UILabel*contentLabel = [[UILabelalloc] initWithFrame:CGRectMake(0,0,
width,0)];
[contentLabel setText:value];
contentLabel.font = [UIFontsystemFontOfSize:fontSize];
contentLabel.numberOfLines=0;
contentLabel.textColor = [UIColorcolorWithRed:27/255.0green:27/255.0blue:27/255.0alpha:1];
// _contentLabel.backgroundColor=[UIColor greenColor];
NSMutableAttributedString *attributedString = [[NSMutableAttributedStringalloc] initWithString:value];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStylealloc] init];
//[paragraphStyle setLineSpacing:5];//调整行间距
[attributedStringaddAttribute:NSParagraphStyleAttributeNamevalue:paragraphStyle range:NSMakeRange(0, [valuelength])];
contentLabel.attributedText = attributedString;
[contentLabel sizeToFit];
NSLog(@"textview:%f++",contentLabel.frame.size.height);
return contentLabel.frame.size.height;
}
- iOS小demo之获取文字高度
- iOS小demo之获取键盘高度
- iOS小demo之获取内存大小
- iOS小demo之获取图片透明度
- iOS小demo之根据路径获取文件大小
- iOS小demo之根据label的宽度计算字符串显示需要的高度
- 获取文字高度
- iOS label根据文字多少获取宽度高度
- android小技巧之---获取状态栏高度
- iOS计算文字高度
- iOS计算文字高度
- iOS文字的高度
- iOS计算文字高度
- ios 计算文字高度
- iOS小demo之判断颜色深浅
- iOS小demo之弹出动画
- iOS小demo之图片变灰
- iOS之旅--开始小demo+整合
- 【LeetCode】6.ZigZag Conversion N型排列问题
- Xcode7 使用NSURLSession发送HTTP请求的问题
- 将 Shiro 作为应用的权限基础 四:shiro的配置说明
- 我参与的项目
- Axure 安装及使用心得
- iOS小demo之获取文字高度
- CentOS 6.5/6.6 安装mysql 5.7 最完整版教程
- Java BeanValidation
- 使用CocoaPods时 显示updating local specs repositories 并且一直不动
- Magento 用了 php 中 ArrayAccess,IteratorAggregate,Countable
- php异常处理笔记
- Android学习资源
- iOS视频边下边播–缓存播放数据流
- 基类和派生类