label 设置行间距 字间距
2015-11-14 04:22
447 查看
#import "MyLabel.h" #import <CoreText/CoreText.h> @implementation MyLabel +(void)setLabel:(UILabel *)custonLabel andContenStr:(NSString *)content andlineSpace:(CGFloat)lineSpace andHeightSpace:(long)fontSpace{ NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:content]; NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; [style setLineSpacing:lineSpace];//行间距 CFNumberRef num = CFNumberCreate(kCFAllocatorDefault,kCFNumberSInt8Type,&fontSpace); [str addAttribute:(id)kCTKernAttributeName value:(__bridge id)num range:NSMakeRange(0, content.length)]; CFRelease(num);//字间距 [str addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, [str length])]; [custonLabel setAttributedText:str]; } @end
相关文章推荐
- Frobenius product
- Openresty + MySQL + Redis 安装篇
- Leetcode Range Sum Query 2D - Immutable
- 教师报课系统测试
- Struts2 防止重复提交
- cryengine3视频教程 CE3 cryengine3中文视频教学
- unigine源代码源码下载 unigine2013游戏引擎源码
- RTTI简介
- RTTI简介
- Lesson 29 SVD decomposition
- [iOS] 建立与使用Framework
- 复数类完整实现 + 四则运算符重载
- C#流言终结者1(当初入门时的一些小实验)
- NYOJ 27 水池数目(dfs)
- 动态类型Dynamic
- win7 vc++ ide 解决方案
- 将python数据结构导出成字符串并自动缩进格式化
- Ofbiz 事务详解
- Leetcode Range Sum Query - Immutable
- NYOJ 1058 部分和问题(dfs)