ios--Attributes和ParagraphStyle介绍
NSMutableParagraphStyle的部分属性:
typedef NS_ENUM(NSInteger, NSLineBreakMode) {/* What to do with long lines */
NSLineBreakByWordWrapping = , /* Wrap at word boundaries, default */
NSLineBreakByCharWrapping,/* Wrap at character boundaries */
NSLineBreakByClipping,/* Simply clip */剪掉后面显示不了的部分
NSLineBreakByTruncatingHead,/* Truncate at head of line: "...wxyz" */头部分的内容以……方式省略
NSLineBreakByTruncatingTail,/* Truncate at tail of line: "abcd..." */结尾部分的内容以……方式省略
NSLineBreakByTruncatingMiddle/* Truncate middle of line: "ab...yz" */中间部分的内容以……方式省略
} NS_ENUM_AVAILABLE_IOS(6_0);
typedef NS_ENUM(NSInteger, NSWritingDirection) {
NSWritingDirectionNatural = -, // Determines direction using the Unicode Bidi Algorithm rules P2 and P3
NSWritingDirectionLeftToRight = , // Left to right writing direction 左到右的书写方向
NSWritingDirectionRightToLeft = // Right to left writing direction 右到左的书写方向
} NS_ENUM_AVAILABLE_IOS(6_0);
// NSParagraphStyleAttributeName 段落的风格(设置首行,行间距,对齐方式什么的)看自己需要什么属性,写什么
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = ;// 字体的行间距
paragraphStyle.firstLineHeadIndent = 20.0f;//首行缩进
paragraphStyle.alignment = NSTextAlignmentJustified;//(两端对齐的)文本对齐方式:(左,中,右,两端对齐,自然)
paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail;//结尾部分的内容以……方式省略 ( "...wxyz" ,"abcd..." ,"ab...yz")
paragraphStyle.headIndent = ;//整体缩进(首行除外)
paragraphStyle.tailIndent = ;//
paragraphStyle.minimumLineHeight = ;//最低行高
paragraphStyle.maximumLineHeight = ;//最大行高
paragraphStyle.paragraphSpacing = ;//段与段之间的间距
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 = ;/* Natural line height is multiplied by this factor (if positive) before being constrained by minimum and maximum line height. */
paragraphStyle.hyphenationFactor = ;//连字属性 在iOS,唯一支持的值分别为0和1
/*
NSFontAttributeName 字体大小
NSParagraphStyleAttributeName 段落的风格(设置首行,行间距,对齐方式什么的)
NSKernAttributeName 字间距
*/
NSDictionary *attributes = @{
NSFontAttributeName:[UIFont systemFontOfSize:],
NSParagraphStyleAttributeName:paragraphStyle,
NSKernAttributeName:@(),
};
textView.attributedText = [[NSAttributedString alloc] initWithString:textView.text attributes:attributes];
1.NSKernAttributeName: @10 调整字句 kerning 字句调整
2.NSFontAttributeName : [UIFont systemFontOfSize:_fontSize] 设置字体
3.NSForegroundColorAttributeName :[UIColor redColor] 设置文字颜色
4.NSParagraphStyleAttributeName : paragraph 设置段落样式
5.NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
paragraph.alignment = NSTextAlignmentCenter;
6.NSBackgroundColorAttributeName: [UIColor blackColor] 设置背景颜色
7.NSStrokeColorAttributeName设置文字描边颜色,需要和NSStrokeWidthAttributeName设置描边宽度,这样就能使文字空心.
NSStrokeWidthAttributeName这个属性所对应的值是一个 NSNumber 对象(小数)。该值改变描边宽度(相对于字体size 的百分比)。默认为 0,即不改变。正数只改变描边宽度。负数同时改变文字的描边和填充宽度。例如,对于常见的空心字,这个值通常为3.0。
同时设置了空心的两个属性,并且NSStrokeWidthAttributeName属性设置为整数,文字前景色就无效果了

效果:


效果:

8. NSStrikethroughStyleAttributeName 添加删除线,strikethrough删除线

效果:

9. NSUnderlineStyleAttributeName 添加下划线

效果:

10. NSShadowAttributeName 设置阴影,单独设置不好使,必须和其他属性搭配才好使。
和这三个任一个都好使,NSVerticalGlyphFormAttributeName,NSObliquenessAttributeName,NSExpansionAttributeName
11.NSVerticalGlyphFormAttributeName
该属性所对应的值是一个 NSNumber 对象(整数)。0 表示横排文本。1 表示竖排文本。在 iOS 中,总是使用横排文本,0 以外的值都未定义。

效果:

12. NSObliquenessAttributeName设置字体倾斜。Skew 斜

效果:

13. NSExpansionAttributeName 设置文本扁平化

效果:

NSMutableParagraphStyle /NSParagraphStyle
ios--Attributes和ParagraphStyle介绍的更多相关文章
- iOS AutoLayout自动布局&Masonry介绍与使用实践
Masonry介绍与使用实践:快速上手Autolayout http://www.cnblogs.com/xiaofeixiang/p/5127825.html http://www.cocoachi ...
- iOS 阶段学习第25天笔记(iOS沙盒机制介绍)
iOS学习(OC语言)知识点整理 一.iOS沙盒机制介绍 1)概念: 每个ios应用都有自己的应用沙盒,应用沙盒就是文件系统目录,与其他应用放入文件 系统隔离,ios系统不允许访问 其他应用的应用沙盒 ...
- iOS沙盒机制介绍,Block 的介绍
一.iOS沙盒机制介绍 (转载) 1)概念:每个ios应用都有自己的应用沙盒,应用沙盒就是文件系统目录,与其他应用放入文件 系统隔离,ios系统不允许访问 其他应用的应用沙盒,但在ios8中已经开放访 ...
- iOS学习之NSBundle介绍和使用
iOS学习之NSBundle介绍和使用 http://blog.csdn.net/totogo2010/article/details/7672271 新建一个Single View Applicat ...
- Visual Studio跨平台开发实战(2) - Xamarin.iOS基本控制项介绍
原文 Visual Studio跨平台开发实战(2) - Xamarin.iOS基本控制项介绍 前言 在上一篇文章中, 我们介绍了Xamarin 以及简单的HelloWorld范例, 这次我们针对iO ...
- iOS 图表工具charts介绍
charts是一个很好的绘图工具,功能非常强大,可以用来绘制折线,柱状图,饼状图,k线图,k线分时图,雷达图,气泡图等等,charts是一款仿照安卓 MPAndroidChart而来的一个基于swif ...
- IOS 学习之 iOS沙盒(sandbox) 介绍 沙盒机制 文件操作(一)
1.iOS沙盒机制 iOS应用程序只能在为该改程序创建的文件系统中读取文件,不可以去其它地方访问,此区域被成为沙盒,所以所有的非代码文件都要保存在此,例如图像,图标,声音,映像,属性列表,文本文件等. ...
- iOS沙盒简单介绍
先简单介绍一下什么是沙盒:你可以简单理解成为一个目录,这个目录的改动不会对操作系统造成任何损失.(这里也有一点点介绍) 看看苹果的沙盒目录: 再附一张苹果官方的图 一个iOS app操作都是在自己的沙 ...
- iOS 证书及配置文件介绍
1.Certification(证书) 证书是对电脑开发资格的认证,每个开发者帐号有一套,分为两种: 1)Developer Certification(开发证书) 安装在电脑上提供权限:开发人员通过 ...
随机推荐
- 导入myeclipse项目出现的问题及解决方案
1.myeclipse 方法上加上@Override就报错 在有@Override方法上面会报错如下: The method oncreate(Bundle) of type HelloWorld m ...
- jQuery.makeArray() 函数详解
jQuery.makeArray()函数用于将一个类数组对象转换为真正的数组对象. 所谓"类数组对象"就是一个常规的Object对象,但它和数组对象非常相似:具备length属性, ...
- JavaScript的prototype(原型)
JavaScript的每一个对象都有prototype属性哦 对象方法.类方法.原型方法 1.对象方法:理解就很简单了,主要是如果类生成一个实例,那么该实例就能使用该方法2.类方法:不需要通过生成实例 ...
- Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
改下build.gradle文件,将里面的compileSdkVersion改为23即可 apply plugin: 'com.android.application' android { compi ...
- SharePoint 2013 创建搜索中心及搜索设置
本文没有太多深奥的东西,只是简单的搜索配置,如果你已经掌握请略过本文. 好了,进入内容简介,众所周知,搜索是SharePoint一大特性,下面,我们简单介绍下搜索中心的创建. 1.创建Search子网 ...
- 获取经过跳转后的url地址
粗略一算,不写code已经好几个月了. 昨日受兄弟所托,为他写了一个小小的程序. 程序功能: 自动获取跳转后的Url地址 如下图所示: (newUrl.txt为转换后的地址信息...) 实现过程: 每 ...
- Interoperability between Java and SharePoint 2013 on Premises
http://ctp-ms.blogspot.com/2012/12/interoperability-between-java-and.html Introduction One of the ...
- Arcengine实现创建网络数据集札记(二)
四 ArcEngine实现创建网络数据集 ArcEngine创建网络数据集的过程,与ArcMap设置的过程类似,主要通过六个步骤即可以实现. 1 定义网络数据集对象,并设置基本属性,包括网络数据集名称 ...
- 【读书笔记】iOS网络-HTTP-URL结构
http://user:password@hostname:port/absolute-path?query. http: 协议 user:password@ 认证 hostname: 主机名 ...
- iOS开发Facebook POP动效库使用教程
如果说Origami这款动效原型工具是Facebook Paper的幕后功臣,那么POP便是Origami的地基.感谢Facebook开源了POP动效库,让人人都能制作出华丽的动效.我们只需5步,便能 ...