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的更多相关文章

  1. 【我的Android进阶之旅】快速创建和根据不同的版本类型(Dev、Beta、Release)发布Android 开发库到Maven私服

    前言 由于项目越来越多,有很多公共的代码都可以抽取出一个开发库出来传到公司搭建好的Maven私服,以供大家使用. 之前搭建的Maven仓库只有Release和Snapshot两个仓库,最近由于开发库有 ...

  2. Hyper-v之利用差异磁盘快速创建多个虚拟机

    在新建Hyper-v磁盘的时候 有3种选项 其中分别是 固定大小 动态扩展 和 差异(differencing,个人习惯叫 差分) 其中 固定大小是新建的时候 Hyper-v创建一个设置大小值的文件, ...

  3. (视频)《快速创建网站》 4.1 为啥造软件不同于造汽车,为啥是软件就一定会有Bug - 构建开发运维一体化(DevOps)

    本文是<快速创建网站>系列的第9篇,如果你还没有看过之前的内容,建议你点击以下目录中的章节先阅读其他内容再回到本文. 访问本系列目录,请点击:http://devopshub.cn/tag ...

  4. (视频) 《快速创建网站》3.4 网站改版3分钟搞定 - WordPress主题安装和备份

    本文是<快速创建网站>系列的第8篇,如果你还没有看过之前的内容,建议你点击以下目录中的章节先阅读其他内容再回到本文. 访问本系列目录,请点击:http://devopshub.cn/tag ...

  5. (视频) 《快速创建网站》1. 网站管理平台WordPress & 微软Azure 云计算简介

    网站并不神秘,过节了,在家闲的没事的,自己建个网站玩玩吧.每段视频不超过15分钟,地铁/公交/睡前/醒来看一段,几天之后变身建站专家,找老板加薪去! 在普通人眼里,创建网站是专业开发人员和IT工程师才 ...

  6. Odoo 配置快速创建编辑按钮

    对于Man2one类型的数据,我们知道,form view中总会显示出一个尾巴似的"create and edit"和一个快速创建的机制,有时候业务人员一不小心就容易创建一个新的行 ...

  7. Foundation框架 - 快速创建跨平台的网站页面原型

    API参考:http://foundation.zurb.com/docs/ 作为网页设计和开发人员,我们面临着以下几个严峻的问题: 每天,人们用来上网的设备种类和数量都在不断上升. 为每种设备设计开 ...

  8. Android开发的初学者快速创建一个项目

    因为gwf的原因,大陆连不上google所以AndroidSDK是无法更新的 而且设置代理也不一定能解决问题 如果是初学者想快速的了解安卓开发,可以在国内的内网下载整合包 下载地址:http://rj ...

  9. 使用laravel 的artisan快速创建表

    参考:使用laravel 的artisan快速创建表 字段类型参考链接: 结构生成器 版本: Laravel 4.2 1. 创建migrate 文件 php artisan migrate:make ...

随机推荐

  1. [Android Memory] 使用 Eclipse Memory Analyzer 进行堆转储文件分析

    转载地址:http://www.ibm.com/developerworks/cn/opensource/os-cn-ecl-ma/index.html Eclipse Memory Analyzer ...

  2. HDU 4901 The Romantic Hero 题解——S.B.S.

    The Romantic Hero Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Othe ...

  3. iOS: 沙盒的详解和目录的获取

    沙盒的详解: •iOS应用程序只能在为该改程序创建的文件系统中读取文件,不可以去其它地方访问,此区域被称为沙盒 •iOS常用目录: –Bundle       //该目录下的文件是用来存储应用程序包的 ...

  4. DICOM:DICOM三大开源库对比分析之“数据加载”

    背景: 上一篇博文DICOM:DICOM万能编辑工具之Sante DICOM Editor介绍了DICOM万能编辑工具,在日常使用过程中发现,“只要Sante DICOM Editor打不开的数据,基 ...

  5. Echarts使用dataset数据集管理数据

    1.可以看官网api的入门例子 使用常见的对象数组的格式 option = { legend: {}, tooltip: {}, dataset: { // 这里指定了维度名的顺序,从而可以利用默认的 ...

  6. 【转】打开linux-tcp端口快速回收

    原文:http://www.zhaoxiaodan.com/lnmp/%E6%89%93%E5%BC%80linux-tcp%E7%AB%AF%E5%8F%A3%E5%BF%AB%E9%80%9F%E ...

  7. 微软 Windows 10 将支持 8 英寸以下 ARM 平板设备

    2015 年 1 月 24 日,  9:32 下午 - 微软本周展示了 Windows 10 一系列新的改变,也包括首次公开展示的 Windows 10 手机版,但 ARM 平板并没有得到太多提及. ...

  8. 华为P6-C00电信版,刷机总是失败? FAIL

    关于这个刷机失败的问题,我只想说一点: 华为P6-C00电信版刷机时,不是任意版本都可以刷到任意版本的.我只往上刷过,那就是华为的升级文档中有说明:“只有以下版本才可以升级到此版本”. 如果你的手机的 ...

  9. android的开发 华为手机上不显示menu键

    android的开发,华为手机上不显示menu键解决办法: 在AndroidManifest.xml中讲targetSdkVersion改为9. <uses-sdk android:minSdk ...

  10. Android应用更新自动检测下载

    由于Android项目开源所致,市面上出现了N多安卓软件市场.为了让我们开发的软件有更多的用户使用,我们需要向N多市场发布,软件升级后,我们也必须到安卓市场上进行更新,给我们增加了工作量.因此我们有必 ...