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. Android设计模式(七)--原型模式

    1.定义: 用原型实例指定创建对象种类,并通过拷贝这些原型创建新的对象. 2.目的: 从一个对象创建另外一个可定制的对象,而不须要知道不论什么创建细节. 3.作用: 3.1.简化对象的创建. 3.2 ...

  2. 关于bootstrap IE8的兼容性问题

    非常久没有写技术类的文章了.这几天在用bootstrap来做我们站点的UI框架,感觉还是不错的.只是遇到一点不大不小的问题,那就是有朋友在IE8下訪问我们的站点.界面变成了跟手机浏览一样的界面. 后来 ...

  3. Eclipse怎么导入外来项目

    从File中点击------>import----->General------>然后按下面的图片显示

  4. Python 面向对象 —— super 的使用(Python 2.x vs Python 3.x)

    注意区分当前的 Python 版本是 2.X 还是 3.X,Python 3.X 在 super 的使用上较之 Python 2.X 有较大的变化: 1. Python 2.x class Conta ...

  5. Apple iMac性能基准测试

    这里我要向大家介绍的一款苹果操作系统下的性能测试软件名叫GeekBench,是加拿大PrimateLabs公司出品. 下载地址:http://www.primatelabs.ca/geekbench/ ...

  6. Vue 国家省市三级联动

    在网上查阅一下,基本上是省市区三级联动,国家省市的就只能自己动手了. 样式就根据自己的需要去调整了. JSON数组太长,就折叠放在了后面. 效果图: <!DOCTYPE html> < ...

  7. 用console.log分析Vue源码

    前言 本文通过console.log的一些特性,结合vue.js的源码,通过一个简单的例子,让你了解Vue的各个过程的变化. 控制台输出的效果图 请用chrome查看,并打开控制台看效果 演示地址 准 ...

  8. [Javascript] Classify JSON text data with machine learning in Natural

    In this lesson, we will learn how to train a Naive Bayes classifier and a Logistic Regression classi ...

  9. 【hadoop之翊】——CentOS6.5 Linux上面编译Hadoop2.4源代码

    今天来说说编译hadoop源代码的事情吧~ 1.首先下载源代码 地址:http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-2.4.0/ 2.加压t ...

  10. python实现获取文件列表中每一个文件keyword

    功能描写叙述: 获取某个路径下的全部文件,提取出每一个文件里出现频率最高的前300个字.保存在数据库其中. 前提.你须要配置好nltk #!/usr/bin/python #coding=utf-8 ...