1. NSDictionary *attributes =@{
  2. NSForegroundColorAttributeName: [UIColorredColor],
  3. NSFontAttributeName: [UIFontfontWithName:@"Zapfino" size:16.0]
  4. };
  5. NSString *strDisplayText =@"This is an attributed string.";
  6. NSAttributedString *attributedText = [[NSAttributedStringalloc] initWithString:strDisplayTextattributes:attributes];
  7. self.lblInfo.attributedText= attributedText;

  1. NSDictionary *attributes1 =@{
  2. NSBackgroundColorAttributeName: [UIColororangeColor],
  3. NSFontAttributeName: [UIFontfontWithName:@"Zapfino" size:22.0],
  4. NSKernAttributeName: @-1.0
  5. };
  6. NSString *strDisplayText1 =@"Orange Background";
  7. NSAttributedString *attributedText1 = [[NSAttributedStringalloc] initWithString:strDisplayText1attributes:attributes1];
  8. self.lblInfo1.attributedText= attributedText1;

  1. NSShadow*shadow = [[NSShadow alloc]init];
  2. shadow.shadowColor = [UIColorgreenColor];
  3. shadow.shadowBlurRadius = 5.0;
  4. shadow.shadowOffset = CGSizeMake(1.0,1.0);
  5. NSDictionary *attributes2 =@{
  6. NSUnderlineStyleAttributeName:@1,
  7. NSShadowAttributeName: shadow
  8. };
  9. NSString *strDisplayText2 =@"Shadow Font";
  10. NSAttributedString *attributedText2 = [[NSAttributedStringalloc] initWithString:strDisplayText2attributes:attributes2];
  11. self.lblInfo2.attributedText= attributedText2;

  1. NSDictionary*subStrAttribute1 = @{
  2. NSForegroundColorAttributeName: [UIColorredColor],
  3. NSStrikethroughStyleAttributeName:@2
  4. };
  5. NSDictionary *subStrAttribute2 =@{
  6. NSForegroundColorAttributeName: [UIColorgreenColor]
  7. };
  8. NSString *strDisplayText3 =@"Red and Green";
  9. NSMutableAttributedString *attributedText3 = [[NSMutableAttributedStringalloc] initWithString:strDisplayText3];
  10. [attributedText3 setAttributes:subStrAttribute1range:NSMakeRange(0,3)];
  11. [attributedText3 setAttributes:subStrAttribute2range:NSMakeRange(8,5)];
  12. self.lblInfo3.attributedText= attributedText3;

  1. //段落样式设置
  2. NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
  3. paragraph.alignment = NSTextAlignmentJustified;
  4. paragraph.firstLineHeadIndent =20.0;
  5. paragraph.paragraphSpacingBefore = 10.0;
  6. paragraph.lineSpacing = 5;
  7. paragraph.hyphenationFactor =1.0;
  8. NSDictionary *attributes4 =@{
  9. NSForegroundColorAttributeName: [UIColorredColor],
  10. NSParagraphStyleAttributeName: paragraph
  11. };
  12. NSString *strDisplayText4 =@“iPad inspires creativity and ……”;
  13. NSAttributedString *attributedText4 = [[NSAttributedStringalloc] initWithString: strDisplayText4attributes:attributes4];
  14. self.lblInfo4.attributedText= attributedText4;
 
0

NSAttributeString创建各种文字效果的更多相关文章

  1. CSS Gradient文字效果

    你想创建的标题没有渲染和Photoshop每个标题吗?这里是一个简单的CSS技巧向您展示如何创建渐变文字效果,PNG图像(纯CSS,没有Javascript或Flash).你所需要的是一个空的< ...

  2. JAVA 跑马灯文字效果

    JAVA跑马灯文字效果的实现: 1. 首先创建一个继承JFrame类的HorseRaceLightTextFrame窗体类,代码如下: package com.example.horseracelig ...

  3. css文字效果(文字剪贴蒙版,text-shodow的应用,文字排版等…)

    .katex { display: inline-block; text-align: initial; } .katex { font-family: Consolas, Inconsolata, ...

  4. 第95天:CSS3 边框、背景和文字效果

    1.CSS3边框: border-radius:CSS3圆角边框.在 CSS2 中添加圆角矩形需要技巧,我们必须为每个圆角使用不同的图片,在 CSS3 中,创建圆角是非常容易的,在 CSS3 中,bo ...

  5. css鼠标滑过出现文字效果

    模仿淘宝上鼠标移动到商品图片时,出现的文字效果. 1.效果图                                鼠标移动到粉红色的区域,则出现黄色部分. 2.代码 <!DOCTYPE ...

  6. Qt qml 模拟iphone slide to unlock 的聚光动画文字效果

    模拟iphone slide to unlock 的聚光动画文字效果    /底层放淡文字    /前景放高亮文字+半透明遮罩    /动画移动遮罩 Author: surfsky.cnblogs.c ...

  7. Progress.js – 为页面上的任意对象创建进度条效果

    Progress.js 是一个 JavaScript 和 CSS3 的库,它帮助开发人员为网页上的每个对象创建和管理进度条效果.你可以设计自己的模板,进度条或者干脆定制. 您可以使用 Progress ...

  8. 【转】使用jquery animate创建平滑滚动效果

    这篇文章主要介绍了使用jquery animate创建平滑滚动效果,效果可以滚动到顶部.到底部或页面中指定地方,生要的是非常平滑,很舒服,需要的朋友可以参考下 滚动到顶部: $('.scroll_to ...

  9. as3.0:文字 效果

    //文字描边效果var tf1 = _root.createTextField("tf1", _root.getNextHighestDepth(), 10, 10, 0, 0); ...

随机推荐

  1. 【Uva 307】Sticks

    [Link]: [Description] 给你最多n个棍子; (n< = 64) 每根棍子长度(1..50) 问你这n根棍子,可以是由多少根长度为x的棍子分割出来的; x要求最小 [Solut ...

  2. CSUOJ 1635 Restaurant Ratings

    1635: Restaurant Ratings Time Limit: 1 Sec  Memory Limit: 128 MB Description A famous travel web sit ...

  3. 模板实参推导 & xx_cast的实现

    首先,类模板必须被显式特化.当然了,可以通过一个辅助函数,通过参数类型,返回特化的类模板,来间接处理. 这个技术被广泛应用在ptr_fun, make_pair, mem_fun, back_inse ...

  4. Java 实现有序链表

    有序链表: 按关键值排序. 删除链头时,就删除最小(/最大)的值,插入时,搜索插入的位置. 插入时须要比較O(N),平均O(N/2),删除最小(/最大)的在链头的数据时效率为O(1), 假设一个应用须 ...

  5. JavaScript版MD5应用

    假设使用Java为一个字符串进行MD5操作,我想轻而易举:但是假设要在client为网页中字符串进行MD5操作又该怎么做呢? 代码1--为字符串等进行MD5操作的js文件(md5.js): /* * ...

  6. 三个角度解构云计算,商业驱动or技术驱动?

    从云计算的使用者到云服务的输出者,大多互联网公司在过去一年完成了角色的转换,也让云计算的未来更加扑朔迷离.不过,抛却进入时间这个评判因素,单从技术和商业化的角度来解构云计算的话,对于云计算的格局以及未 ...

  7. html的学习思维导图

  8. 43.可变参数实现printf

    #include <stdio.h> #include <stdio.h> #include <Windows.h> #include <stdarg.h&g ...

  9. Domino系统从UNIX平台到windows平台的迁移及备份

    单位机房的一台服务机器到折旧期了,换成了新购IBM机器X3950,而且都预装了windows 2003 server 标准版,所以只有把以前在Unix平台下跑的OA系统迁移到新的windows 200 ...

  10. web api 特点

    webapi有很多特点(我不想用优点这个词),比如说restful,支持路由,简单,类似mvc controller/action的代码编写方式,灵活的托管方式,和web的集成等等. Web API的 ...