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. Selenium_WebDriver操作iFrame日历框和复选框_Java

    iFrame日历框 页面上遇到iFrame元素时,先用findElement找到这个iFrame元素,然后再WebDriver.switchTo().frame(calFrame).在iFrame里操 ...

  2. PHP CLI模式下的多进程应用分析

    PHP在非常多时候不适合做常驻的SHELL进程, 他没有专门的gc例程, 也没有有效的内存管理途径. 所以假设用PHP做常驻SHELL, 你会常常被内存耗尽导致abort而unhappy 并且, 假设 ...

  3. modSecurity规则学习(三)——SecRule

    通用格式 SecRule VARIABLES OPERATOR [TRANSFORMATION_FUNCTIONS, ACTIONS]   阶段phase (1)request headers (2) ...

  4. Android官方文档翻译——Fragment生命周期

    网上有的博客写得太乱 不如自己翻译官方文档 Lifecycle 生命周期 Though a Fragment's lifecycle is tied to its owning activity, i ...

  5. es6 --- var const let

    var  const   let  区别 今天第一次遇到const定义的变量,查阅了相关资料整理了这篇文章.主要内容是:js中三种定义变量的方式const, var, let的区别. 1. const ...

  6. javafx checkbox

    public class EffectTest extends Application { public static void main(String[] args) { launch(args); ...

  7. 2229: [Zjoi2011]最小割(最小割树)

    Description 小白在图论课上学到了一个新的概念——最小割,下课后小白在笔记本上写下了如下这段话: “对于一个图,某个对图中结点的划分将图中所有结点分成两个部分,如果结点s,t不在同一个部分中 ...

  8. fc---输出历史命令列表

    fc指令 fc指令可以用于输出历史命令列表,也可以通过调用vi编辑器对历史指令内容进行编辑输出. 语法: fc [-e ename] [-lnr] [first] [last] 选项: -l:显示历史 ...

  9. 【Python】【Head First Python】【chapter1】2 - sys.stdout 和 print 的区别

    sys.stdout 和 print 的区别 首先,通过 help(print) 得到print内建函数的参数 Help on built-in function print in module bu ...

  10. 如何优雅的写UI——(2)MFC下基于CFormView的文档视图程序

    在MFC中可以创建多种类型的窗口程序,如对话框程序.单文档结构程序(非文档/视图结构).单文档(文档/视图结构)以及多文档视图结构程序等. 在编写一般的小工具时,我们的首选显然是对话框程序,不过基于对 ...