UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
label.font = [UIFont systemFontOfSize:14];
label.numberOfLines = 0;
[self.view addSubview:label];
[label mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(20);
make.right.offset(-20);
make.top.offset(160);
}];
NSString * desc = @"这是一段titlte文案,这是一段titlte文案,这是一段titlte文案,这是一段titlte文案后面是一个换行\nThis morning (March 29th), most cities and counties in Guangdong were cloudy and covered with light fog. Some areas in Qingyuan, Shaoguan and Zhaoqing saw dense fog with visibility of less than 500 meters.\n\n这是一段titlte文案,后面是一个换行\n";
NSMutableParagraphStyle * style = [NSMutableParagraphStyle defaultParagraphStyle].mutableCopy;
style.paragraphSpacing = 10; //当前段落和下一个段落的距离
style.paragraphSpacingBefore = 5;//当前段落和上一个段落的距离
style.lineSpacing = 20;//当前行和下一行的距离,空白行也存在间距,这个间距在行下
// style.lineHeightMultiple = 2.0; //这个间距在行上
style.firstLineHeadIndent = 30; //当前段落第一行的偏移量
style.headIndent = 20; //当前段落其他行的偏移量
style.lineBreakMode = NSLineBreakByWordWrapping;//截断模式
// style.tailIndent = -16; //为正数时代表显示宽度,为负数时代表距离右边的间距
// style.alignment = NSTextAlignmentRight; //对齐方式
//书写方向
// style.baseWritingDirection = NSWritingDirectionRightToLeft;
style.hyphenationFactor = 1.0; //0 or 1
NSDictionary * dict = @{
NSFontAttributeName:[UIFont systemFontOfSize:18],
NSForegroundColorAttributeName:[UIColor blackColor],
NSParagraphStyleAttributeName:style,
NSBackgroundColorAttributeName:[UIColor redColor]
};
NSAttributedString * attr = [[NSAttributedString alloc] initWithString:desc attributes:dict];
label.attributedText = attr;

NSParagraphStyle 的属性的更多相关文章

  1. jqu

    1 /*2 * 说明:3 * 本源代码的中文注释乃Auscarlin呕心沥血所作.旨在促进jQuery的传播以及向广大jQuery爱好者提供一个进阶4 *的途径,以让各位更加深入地了解jQuery,学 ...

  2. iOS-文本段落样式NSMutableParagraphStyle与NSParagraphStyle的使用和一些富文本处理属性

    开发过程中,经常会遇到动态计算行高的问题, - (CGRect)boundingRectWithSize:(CGSize)size options:(NSStringDrawingOptions)op ...

  3. iOS-字符属性NSAttributedString描述

    /* 字符属性 字符属性可以应用于 attributed string 的文本中. NSString *const NSFontAttributeName;(字体) NSString *const N ...

  4. Attributes:文本属性 和NSAttributedString

    前言: 有一些控件无法直接设置文本大小,需要使用方法 setTitleTextAttributes 来设置文本属性 UIFont 字体样式 [UIFont fontWithName~]; iOS- 详 ...

  5. 修改UIBarButtonItem字体大小、颜色等相关属性

    在ios中如果想修改UIBarButtonItem里面的内容有很多种方法,常见的就是自定义contentView  但是有时候因为懒不想自定义只想在原来的文字上进行修改 如果只是修改UIBarButt ...

  6. UIlabel - 富文本属性

    1.NSKernAttributeName: @10 调整字句 kerning 字句调整 2.NSFontAttributeName : [UIFont systemFontOfSize:_fontS ...

  7. NSAttributedString 的21种属性 详解

    原文链接:http://www.jianshu.com/p/09f54730feaa 先看看所有的Key NSFontAttributeName; //字体,value是UIFont对象 NSPara ...

  8. 设置UINavigationController标题的属性

    设置UINavigationController标题的属性 self.title = @"产品详情"; [self.navigationController.navigationB ...

  9. iOS自学-UILabel常见属性

    #import "ViewController.h" #import <CoreText/CoreText.h> @interface ViewController ( ...

随机推荐

  1. (转载)IQueryable和IEnumerable

    第一篇:https://www.cnblogs.com/zgqys1980/p/4047315.html: 第二篇:https://www.cnblogs.com/shenbing/p/5394228 ...

  2. C# 反射 判断类的延伸类型

    判断类型是否被继承.实现 1.判断是否实现了指定接口 添加测试类: public class TestClass2 : TestClass1 { } public class TestClass1 : ...

  3. oracle学习笔记(二) 基本数据类型

    常用的数据类型 int number number(4,1) 999.1 四个数字,小数位一位 decimal date 日期 格式如下: 注意:日期类型的字段格式,可以通过以下三种方式: 1. da ...

  4. Biorhythms(poj1006+中国剩余定理)

    Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 117973   Accepted: 37026 Des ...

  5. 山西大同大学教务处学生端--送给学弟,学妹的礼物,可在PC端,手机端操作

    解决问题:大同大学教务处官网学生端口一进去就卡住了,点上面一行的菜单无响应 转眼已是四年,想想自己大学即将结束,不由得让人感慨啊.这才刚开学几天,我就听到有同学在因为补考,选课的事情发愁.学校官方的教 ...

  6. CAD 在ARCGIS中的坐标系问题

    近期在使用服务(文本写入dxf方式)导出CAD的时候发现导出的CAD文件和原始数据在ArcMap中叠加后不能重合,出现了错位的现象. 查看CAD文件后发现CAD的坐标系及投影和数据不一致导致的.遇到这 ...

  7. Python笔记-高级特性

    1.迭代 如果给定一个list或tuple,我们可以通过for循环来遍历这个list或tuple,这种遍历我们称为迭代(Iteration). 如果要迭代value,可以用for value in d ...

  8. Android Studio打包SDK后,为什么没有bundles文件夹?

    在Android Studio中,将项目打包成jar包,按照网上说的方法打包完成后,在intermediates文件夹下没有bundles,AS版本3.1.2,后来发现,原来是intermediate ...

  9. 网络基础 外网IP,内网IP,虚拟机的网络设置

    外网IP,内网IP的关系 在这三类地址中,绝大多数的IP地址都是公有地址,需要向国际互联网信息中心申请注册.但是在IPv4地址协议中预留了3个IP地址段,作为私有地址,供组织机构内部使用. 这三个地址 ...

  10. day 25 面向对象之接口、抽象类、多态、异常处理、反射、断言

    复习 '''继承​1.父类:在类后()中写父类们class A:passclass B:passclass C(A, B):pass​2.属性查找顺序:自己 -> ()左侧的父类 -> 依 ...