//   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相关推荐

  1. ios 中的小技巧 - 总有你想要的 一

    UITableView的Group样式下顶部空白处理 在viewWillAppear里面添加如下代码: //分组列表头部空白处理 CGRect frame = myTableView.tableHea ...

  2. IOS开发 使用CGContextRef绘制文字时的设置

    NSString *str = @"hello";//字体UIFont *font = [UIFont systemFontOfSize:16.0];//文本风格,设置居中NSMu ...

  3. 你想要的iOS 小技巧总结

    UITableView的Group样式下顶部空白处理 //分组列表头部空白处理 UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0 ...

  4. iOS 选择的照片或者拍照的图片上添加日期水印

    1..引入框架 #import "CLLocation+GPSDictionary.h" #import "NSDictionary+CLLocation.h" ...

  5. 【转】iphone开发中NSMutableAttributedString/NSAttributedString 富文本设置

    http://stackoverflow.com/questions/11031623/how-can-i-use-attributedtext-in-uilabel 一.设置UILabel的属性at ...

  6. iOS字符串处理笔记(正则表达式、NSScanner扫描、CoreParse解析器)

    搜索 在一个字符串中搜索子字符串 最灵活的方法 1 - (NSRange)rangeOfString:(NSString *)aString options:(NSStringCompareOptio ...

  7. 关于drawInRect: withAttributes: 等新方法的使用

    新的方法采用的是 attributes,attributes参数需要的是一个数组 我们常用的有几个: NSMutableParagraphStyle* paragraphStyle = [[NSPar ...

  8. UILabel的使用

    1.自动适配 2.设置label 的边距 NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] muta ...

  9. 控件 UIView UILabel UITextField UITextView UIButton ;的字体、大小、单位、颜色

    转自:http://www.tuicool.com/articles/QZ3If2 //学习内容/*1.控件 UIView UILabel UITextField UITextView UIButto ...

最新文章

  1. 985大学的高材生只会写代码片段,丢人吗?
  2. 在leangoo里怎么设置背景,修改密码?
  3. qtcreator cannot find -lts
  4. Java 序列化Serializable详解(附详细例子)
  5. java注释日志打印_java 注解结合 spring aop 实现自动输出日志
  6. 全面改革:解读 Vue 3.0 的变化
  7. Spring Boot Lombok配置
  8. cocos2dx进阶学习之CCAction
  9. asp.net多图片上传同时保存对每张图片的描述
  10. MATLAB: 你不知道的12个基础知识
  11. 关于CSS的fixed定位
  12. php array_change_key_case()
  13. 学计算机干眼,​长期使用电脑 小心干眼症
  14. linux添加多网站,linux添加多个网站-微笑の风
  15. 浙江理工大学计算机考研资料汇总
  16. html中如何显示代码样式方法
  17. 水漆哪个品牌好?十大品牌水漆排行榜
  18. 11个好玩有趣的网站,一打开就停不下来
  19. 小甲鱼第5章:列表、元组和字符串(半整理)
  20. win7旗舰恢复出厂设置_教你把电脑恢复出厂设置。

热门文章

  1. 读写EEPROM遇到的问题:16位地址的内容都是最后写入的数据。
  2. CTFshow php特性 web130
  3. table1函数----一维查表
  4. Kth Largest Element in an Array
  5. matplotlib显示中文(显现中文之后负号无法显示)
  6. 2.2.5 Adam优化算法
  7. A. A Prank
  8. 获取input数据_使用 PHP Masked Package 屏蔽敏感数据
  9. MS SQL SERVER导出表结构到Excel
  10. UVa 122 Trees on the level