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. gpu和cpu区别

    GPU的功耗远远超过CPUCache, local memory: CPU > GPU Threads(线程数): GPU > CPURegisters: GPU > CPU 多寄存 ...

  2. iOS:UI简单的总结

    UI简单总结: 一.常用单例: NSBundle *bundel = [NSBundle mainBundle]; //加载资源 NSFileManager *fm = [NSFileManager  ...

  3. OpenGL: 你不知道的左右手坐标系

    左右手坐标系 众所周知,OpenGL使用的是右手坐标系,而Direct3D使用的是左手坐标系. 除了上面Z轴的方向不一样外,左右手坐标系的还有其他区别: 正向旋转方向:在左手系中用Left-Hand ...

  4. 进程控制块(PCB)结构

    一.进程控制块(PCB)结构 进程控制块(PCB)是系统为了管理进程设置的一个专门的数据结构.系统用它来记录进程的外部特征,描述进程的运动变化过程.同时,系统可以利用PCB来控制和管理进程,所以说,P ...

  5. python爬虫——利用BeautifulSoup4爬取糗事百科的段子

    import requests from bs4 import BeautifulSoup as bs #获取单个页面的源代码网页 def gethtml(pagenum): url = 'http: ...

  6. js轮播功能 标签自动切换 同页面多轮播js

    需要加入jquery 1.43及以上版本 下面还有个简单版,一个页面只支持一个轮播 同页面多轮播js <div> <div class="yt_content"& ...

  7. php 获得linux 机器的性能

    <?php $str = shell_exec('more /proc/stat'); $pattern = "/(cpu[0-9]? )[\s]+([0-9]+)[\s]+([0-9 ...

  8. 再谈Cognos报表设计中的维度函数

    在报表设计的过程中,客户很多时候会想看同比.环比的数据,很多人会想到利用日期函数在数据库中处理好然后直接在报表拖出来使用,其实这样加大了数据库的压力,当然也是解决问题的一种思路.今天我们就来说一下如何 ...

  9. android KK版本号收到短信后,点亮屏的操作

    alps/packages/apps/mms/src/comandroid\mms\transation\MessagingNotification.java private static void ...

  10. taro 填坑之路(一)taro 项目回顾

    (1)像素写法 PX -- 大写,否则会自动成rem (2)拿取列表第一条数据 let { activity:[firstItem] } = this.state; (3)使用props 需要设置默认 ...