NSMutableParagraphStyle /NSParagraphStyle
// NSParagraphStyleAttributeName 段落的风格(设置首行,行间距,对齐方式什么的)看自己需要什么属性,写什么 NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; paragraphStyle.lineSpacing = 10;// 字体的行间距 paragraphStyle.firstLineHeadIndent = 20.0f;//首行缩进 paragraphStyle.alignment = NSTextAlignmentJustified;//(两端对齐的)文本对齐方式:(左,中,右,两端对齐,自然) paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail;//结尾部分的内容以……方式省略 ( "...wxyz" ,"abcd..." ,"ab...yz") paragraphStyle.headIndent = 20;//整体缩进(首行除外) paragraphStyle.tailIndent = 20;// paragraphStyle.minimumLineHeight = 10;//最低行高 paragraphStyle.maximumLineHeight = 20;//最大行高 paragraphStyle.paragraphSpacing = 15;//段与段之间的间距 paragraphStyle.paragraphSpacingBefore = 22.0f;// 段首行空白空间 /* Distance between the bottom of the previous paragraph (or the end of its paragraphSpacing, if any) and the top of this paragraph. */ paragraphStyle.baseWritingDirection = NSWritingDirectionLeftToRight;//从左到右的书写方向(一共➡️三种) paragraphStyle.lineHeightMultiple = 15;/* Natural line height is multiplied by this factor (if positive) before being constrained by minimum and maximum line height. */ paragraphStyle.hyphenationFactor = 1;//连字属性 在iOS,唯一支持的值分别为0和1 /* NSFontAttributeName 字体大小 NSParagraphStyleAttributeName 段落的风格(设置首行,行间距,对齐方式什么的) NSKernAttributeName 字间距 */ NSDictionary *attributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:15], NSParagraphStyleAttributeName:paragraphStyle, NSKernAttributeName:@(10), }; textView.attributedText = [[NSAttributedString alloc] initWithString:textView.text attributes:attributes];
转载于:https://www.cnblogs.com/heng-hengHenry/p/5653780.html
NSMutableParagraphStyle /NSParagraphStyle相关推荐
- ios 中的小技巧 - 总有你想要的 一
UITableView的Group样式下顶部空白处理 在viewWillAppear里面添加如下代码: //分组列表头部空白处理 CGRect frame = myTableView.tableHea ...
- IOS开发 使用CGContextRef绘制文字时的设置
NSString *str = @"hello";//字体UIFont *font = [UIFont systemFontOfSize:16.0];//文本风格,设置居中NSMu ...
- 你想要的iOS 小技巧总结
UITableView的Group样式下顶部空白处理 //分组列表头部空白处理 UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0 ...
- iOS 选择的照片或者拍照的图片上添加日期水印
1..引入框架 #import "CLLocation+GPSDictionary.h" #import "NSDictionary+CLLocation.h" ...
- 【转】iphone开发中NSMutableAttributedString/NSAttributedString 富文本设置
http://stackoverflow.com/questions/11031623/how-can-i-use-attributedtext-in-uilabel 一.设置UILabel的属性at ...
- iOS字符串处理笔记(正则表达式、NSScanner扫描、CoreParse解析器)
搜索 在一个字符串中搜索子字符串 最灵活的方法 1 - (NSRange)rangeOfString:(NSString *)aString options:(NSStringCompareOptio ...
- 关于drawInRect: withAttributes: 等新方法的使用
新的方法采用的是 attributes,attributes参数需要的是一个数组 我们常用的有几个: NSMutableParagraphStyle* paragraphStyle = [[NSPar ...
- UILabel的使用
1.自动适配 2.设置label 的边距 NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] muta ...
- 控件 UIView UILabel UITextField UITextView UIButton ;的字体、大小、单位、颜色
转自:http://www.tuicool.com/articles/QZ3If2 //学习内容/*1.控件 UIView UILabel UITextField UITextView UIButto ...
最新文章
- 985大学的高材生只会写代码片段,丢人吗?
- 在leangoo里怎么设置背景,修改密码?
- qtcreator cannot find -lts
- Java 序列化Serializable详解(附详细例子)
- java注释日志打印_java 注解结合 spring aop 实现自动输出日志
- 全面改革:解读 Vue 3.0 的变化
- Spring Boot Lombok配置
- cocos2dx进阶学习之CCAction
- asp.net多图片上传同时保存对每张图片的描述
- MATLAB: 你不知道的12个基础知识
- 关于CSS的fixed定位
- php array_change_key_case()
- 学计算机干眼,​长期使用电脑 小心干眼症
- linux添加多网站,linux添加多个网站-微笑の风
- 浙江理工大学计算机考研资料汇总
- html中如何显示代码样式方法
- 水漆哪个品牌好?十大品牌水漆排行榜
- 11个好玩有趣的网站,一打开就停不下来
- 小甲鱼第5章:列表、元组和字符串(半整理)
- win7旗舰恢复出厂设置_教你把电脑恢复出厂设置。