快速创建各种类型的NSAttributeString和NSMutableParagraphStyle

NSDictionary *attributes = @{ NSForegroundColorAttributeName : [ UIColorredColor
],
NSFontAttributeName : [ UIFont fontWithName : @"Zapfino" size : 16.0
]
}
;
NSString *strDisplayText = @"This is an attributed string."
;
NSAttributedString *attributedText = [[ NSAttributedString alloc ] initWithString:strDisplayText attributes
:attributes];
self . lblInfo . attributedText = attributedText;

NSDictionary *attributes1 = @{
NSBackgroundColorAttributeName : [ UIColor orangeColor ],
NSFontAttributeName : [ UIFont fontWithName : @"Zapfino" size : 22.0 ],
NSKernAttributeName : @- 1.0
} ;
NSString *strDisplayText1 = @"Orange Background" ;
NSAttributedString *attributedText1 = [[ NSAttributedString alloc ] initWithString:strDisplayText1 attributes :attributes1];
self . lblInfo1 . attributedText = attributedText1;

NSShadow *shadow = [[ NSShadow alloc ] init ];
shadow. shadowColor = [ UIColor greenColor ];
shadow. shadowBlurRadius = 5.0 ;
shadow. shadowOffset = CGSizeMake ( 1.0 , 1.0 );
NSDictionary *attributes2 = @{
NSUnderlineStyleAttributeName : @1 ,
NSShadowAttributeName : shadow
} ;
NSString *strDisplayText2 = @"Shadow Font" ;
NSAttributedString *attributedText2 = [[ NSAttributedString alloc ] initWithString:strDisplayText2 attributes :attributes2];
self . lblInfo2 . attributedText = attributedText2;

NSDictionary *subStrAttribute1 = @{
NSForegroundColorAttributeName : [ UIColor redColor ],
NSStrikethroughStyleAttributeName : @2
} ;
NSDictionary *subStrAttribute2 = @{
NSForegroundColorAttributeName : [ UIColor greenColor ]
} ;
NSString *strDisplayText3 = @"Red and Green" ;
NSMutableAttributedString *attributedText3 = [[ NSMutableAttributedString alloc ]initWithString :strDisplayText3];
[attributedText3 setAttributes :subStrAttribute1 range : NSMakeRange ( 0 , 3 )];
[attributedText3 setAttributes :subStrAttribute2 range : NSMakeRange ( 8 , 5 )];
self . lblInfo3 . attributedText = attributedText3;

NSMutableParagraphStyle *paragraph = [[ NSMutableParagraphStyle alloc ] init
];
paragraph.
alignment = NSTextAlignmentJustified
;
paragraph.
firstLineHeadIndent = 20.0
;
paragraph.
paragraphSpacingBefore = 10.0
;
paragraph.
lineSpacing = 5
;
paragraph.
hyphenationFactor = 1.0
;
NSDictionary *attributes4 = @{ NSForegroundColorAttributeName : [ UIColorredColor
],
NSParagraphStyleAttributeName : paragraph }
;
NSString *strDisplayText4 = @“iPad inspires creativity and ……”
;
NSAttributedString *attributedText4 = [[ NSAttributedString alloc ] initWithString : strDisplayText4 attributes :attributes4];
self . lblInfo4 . attributedText = attributedText4;
快速创建各种类型的NSAttributeString和NSMutableParagraphStyle的更多相关文章
- 【我的Android进阶之旅】快速创建和根据不同的版本类型(Dev、Beta、Release)发布Android 开发库到Maven私服
前言 由于项目越来越多,有很多公共的代码都可以抽取出一个开发库出来传到公司搭建好的Maven私服,以供大家使用. 之前搭建的Maven仓库只有Release和Snapshot两个仓库,最近由于开发库有 ...
- Hyper-v之利用差异磁盘快速创建多个虚拟机
在新建Hyper-v磁盘的时候 有3种选项 其中分别是 固定大小 动态扩展 和 差异(differencing,个人习惯叫 差分) 其中 固定大小是新建的时候 Hyper-v创建一个设置大小值的文件, ...
- (视频)《快速创建网站》 4.1 为啥造软件不同于造汽车,为啥是软件就一定会有Bug - 构建开发运维一体化(DevOps)
本文是<快速创建网站>系列的第9篇,如果你还没有看过之前的内容,建议你点击以下目录中的章节先阅读其他内容再回到本文. 访问本系列目录,请点击:http://devopshub.cn/tag ...
- (视频) 《快速创建网站》3.4 网站改版3分钟搞定 - WordPress主题安装和备份
本文是<快速创建网站>系列的第8篇,如果你还没有看过之前的内容,建议你点击以下目录中的章节先阅读其他内容再回到本文. 访问本系列目录,请点击:http://devopshub.cn/tag ...
- (视频) 《快速创建网站》1. 网站管理平台WordPress & 微软Azure 云计算简介
网站并不神秘,过节了,在家闲的没事的,自己建个网站玩玩吧.每段视频不超过15分钟,地铁/公交/睡前/醒来看一段,几天之后变身建站专家,找老板加薪去! 在普通人眼里,创建网站是专业开发人员和IT工程师才 ...
- Odoo 配置快速创建编辑按钮
对于Man2one类型的数据,我们知道,form view中总会显示出一个尾巴似的"create and edit"和一个快速创建的机制,有时候业务人员一不小心就容易创建一个新的行 ...
- Foundation框架 - 快速创建跨平台的网站页面原型
API参考:http://foundation.zurb.com/docs/ 作为网页设计和开发人员,我们面临着以下几个严峻的问题: 每天,人们用来上网的设备种类和数量都在不断上升. 为每种设备设计开 ...
- Android开发的初学者快速创建一个项目
因为gwf的原因,大陆连不上google所以AndroidSDK是无法更新的 而且设置代理也不一定能解决问题 如果是初学者想快速的了解安卓开发,可以在国内的内网下载整合包 下载地址:http://rj ...
- 使用laravel 的artisan快速创建表
参考:使用laravel 的artisan快速创建表 字段类型参考链接: 结构生成器 版本: Laravel 4.2 1. 创建migrate 文件 php artisan migrate:make ...
随机推荐
- IIS7的CMD指令
AppCmd.exe工具所在目录 C:\windows\sytstem32\inetsrv\目录下 使用命令行管理IIS 7.0时,需要使用IIS7.0提供的全新管理工具AppCmd.exe.AppC ...
- go语言基础之类型别名
1.类型别名 示例: package main //必须有一个main包 import "fmt" func main() { //给int64起一个别名叫bigint type ...
- Windows MongoDB安装配置
1.下载 官网:http://www.runoob.com/mongodb/mongodb-window-install.html 由于是在window下,所以我下载的是mongodb-win32-x ...
- Android -- 压缩与解压文件
我在做一个项目中,工程文件中有一个功能需要很多图片,图片与app一起打包下来的话有30+M,那么我们就考虑另外下载压缩包,我们将图片取出,工程就只有4+M了,哈哈哈哈,呵呵,真恐怖.那么这样就涉及到另 ...
- python中各类时间的计算
python获取当前系统时间: nowTime=time.localtime() 获取当前系统日期: nowDate=datetime.datetime(nowTime[0],nowTime[1],n ...
- java对象的强引用,软引用,弱引用和虚引用
1.强引用 以前我们使用的大部分引用实际上都是强引用,这是使用最普遍的引用.如果一个对象具有强引用,那就类似于必不可少的生活用品,垃圾回收器绝不会回收它.当内存空 间不足,Java虚拟机宁愿抛出Out ...
- How to add a button in the seletions "More"
<?xml version="1.0" encoding="utf-8"?> <openerp> <data> <re ...
- Java之深入JVM(6) - 字节码执行引擎(转)
本文为转载,来自 前面我们不止一次的提到,Java是一种跨平台的语言,为什么可以跨平台,因为我们编译的结果是中间代码—字节码,而不是机器码,那字节码在整个Java平台扮演着什么样的角色的呢?JDK1. ...
- spring AOP编程--AspectJ注解方式
1. AOP 简介 AOP(Aspect-Oriented Programming, 面向切面编程): 是一种新的方法论, 是对传统 OOP(Object-Oriented Programming, ...
- java FileI(O)nputStream为什么比BufferedI(O)utputStream慢?
因为buffered多了一个缓冲区,读和写都是先把硬盘或者内存中的数据放到内存中一块缓存区域,到一定大小读写到硬盘或者内存 package io; import java.io.*; public ...