NSParagraphStyle 的属性
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 的属性的更多相关文章
- jqu
1 /*2 * 说明:3 * 本源代码的中文注释乃Auscarlin呕心沥血所作.旨在促进jQuery的传播以及向广大jQuery爱好者提供一个进阶4 *的途径,以让各位更加深入地了解jQuery,学 ...
- iOS-文本段落样式NSMutableParagraphStyle与NSParagraphStyle的使用和一些富文本处理属性
开发过程中,经常会遇到动态计算行高的问题, - (CGRect)boundingRectWithSize:(CGSize)size options:(NSStringDrawingOptions)op ...
- iOS-字符属性NSAttributedString描述
/* 字符属性 字符属性可以应用于 attributed string 的文本中. NSString *const NSFontAttributeName;(字体) NSString *const N ...
- Attributes:文本属性 和NSAttributedString
前言: 有一些控件无法直接设置文本大小,需要使用方法 setTitleTextAttributes 来设置文本属性 UIFont 字体样式 [UIFont fontWithName~]; iOS- 详 ...
- 修改UIBarButtonItem字体大小、颜色等相关属性
在ios中如果想修改UIBarButtonItem里面的内容有很多种方法,常见的就是自定义contentView 但是有时候因为懒不想自定义只想在原来的文字上进行修改 如果只是修改UIBarButt ...
- UIlabel - 富文本属性
1.NSKernAttributeName: @10 调整字句 kerning 字句调整 2.NSFontAttributeName : [UIFont systemFontOfSize:_fontS ...
- NSAttributedString 的21种属性 详解
原文链接:http://www.jianshu.com/p/09f54730feaa 先看看所有的Key NSFontAttributeName; //字体,value是UIFont对象 NSPara ...
- 设置UINavigationController标题的属性
设置UINavigationController标题的属性 self.title = @"产品详情"; [self.navigationController.navigationB ...
- iOS自学-UILabel常见属性
#import "ViewController.h" #import <CoreText/CoreText.h> @interface ViewController ( ...
随机推荐
- Python3 日期与时间戳相互转换
开发中经常会对时间格式处理,对于时间数据,比如2019-02-28 10:23:29,有时需要日期与时间戳进行相互转换,在Python3中主要用到time模块,相关的函数如下: 其中unix_time ...
- ConcurrentHashMap1.8源码分析
文章简介 想必大家对HashMap数据结构并不陌生,JDK1.7采用的是数组+链表的方式,JDK1.8采用的是数组+链表+红黑树的方式.虽然JDK1.8对于HashMap有了很大的改进,提高了存取效率 ...
- SpringMVC之入门程序
SpringMVC之入门程序——使用浏览器展示商品数据 springMVC执行流程(图片来源:https://www.jianshu.com/p/8a20c547e245) 1.创建pojo(商品实体 ...
- Program Thread 和 Process的不同点
Thread is for execution Kernel level thread, physical parallelism Cores Divide work amount of physic ...
- nginx系列7:处理HTTP请求的11个阶段
处理HTTP请求的11个阶段 如下图: 序号 阶段 指令 备注 1 POST_READ realip 获取客户端真实IP 2 SERVER_REWRITE rewrite 3 FIND_CONFIG ...
- 008. 阻塞&非阻塞、同步&异步
阻塞 非阻塞:关注的对象是调用者: 阻塞:调用者发起调用后,处于等待状态,直到该调用有返回: 非阻塞:调用者发起调用后,不需要等待返回,可以往下执行: 同步 异步: 关注的对象是被调用者: 同步:服 ...
- 常见的7种XSS
1. URL Reflection 当URL以某种方式反映在源代码中时,我们可以添加自己的XSS向量/有效负载.对于PHP页面,可以使用斜杠字符(/)在页面名称之后添加任何内容 http://brut ...
- android - TextView单行显示...或者文字左右滚动(走马灯效果)
条件 TextView单行显示,文字左右滚动(走马灯效果)实现条件: 实现单行设置固定宽度或者设置权重都行 代码 TextView滚动必须写下面几个属性 android:singleLine=&quo ...
- 问题解决--无法解析的外部符号 _imp_XXXXXXXXX
错误示例: 出现字符_imp,说明不是真正的静态库,而是某个动态库的导入库,导入函数和自己不同名,所以加了字符_imp.比如说_imp_GetUserNameA就是GetUserNameA函数. 会报 ...
- d3.svg.line()错误:TypeError: d3.svg.line is not a function
var line_generator= d3.svg.line() .x(function (d,i) { return i; }) .y(function (d) { return d; }) 错误 ...