NSAttributeString创建各种文字效果
- NSDictionary *attributes =@{
- NSForegroundColorAttributeName: [UIColorredColor],
- NSFontAttributeName: [UIFontfontWithName:@"Zapfino" size:16.0]
- };
- NSString *strDisplayText =@"This is an attributed string.";
- NSAttributedString *attributedText = [[NSAttributedStringalloc] initWithString:strDisplayTextattributes:attributes];
- self.lblInfo.attributedText= attributedText;
- NSDictionary *attributes1 =@{
- NSBackgroundColorAttributeName: [UIColororangeColor],
- NSFontAttributeName: [UIFontfontWithName:@"Zapfino" size:22.0],
- NSKernAttributeName: @-1.0
- };
- NSString *strDisplayText1 =@"Orange Background";
- NSAttributedString *attributedText1 = [[NSAttributedStringalloc] initWithString:strDisplayText1attributes:attributes1];
- self.lblInfo1.attributedText= attributedText1;
- NSShadow*shadow = [[NSShadow alloc]init];
- shadow.shadowColor = [UIColorgreenColor];
- shadow.shadowBlurRadius = 5.0;
- shadow.shadowOffset = CGSizeMake(1.0,1.0);
- NSDictionary *attributes2 =@{
- NSUnderlineStyleAttributeName:@1,
- NSShadowAttributeName: shadow
- };
- NSString *strDisplayText2 =@"Shadow Font";
- NSAttributedString *attributedText2 = [[NSAttributedStringalloc] initWithString:strDisplayText2attributes:attributes2];
- self.lblInfo2.attributedText= attributedText2;
- NSDictionary*subStrAttribute1 = @{
- NSForegroundColorAttributeName: [UIColorredColor],
- NSStrikethroughStyleAttributeName:@2
- };
- NSDictionary *subStrAttribute2 =@{
- NSForegroundColorAttributeName: [UIColorgreenColor]
- };
- NSString *strDisplayText3 =@"Red and Green";
- NSMutableAttributedString *attributedText3 = [[NSMutableAttributedStringalloc] initWithString:strDisplayText3];
- [attributedText3 setAttributes:subStrAttribute1range:NSMakeRange(0,3)];
- [attributedText3 setAttributes:subStrAttribute2range: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 = [[NSAttributedStringalloc] initWithString: strDisplayText4attributes:attributes4];
- self.lblInfo4.attributedText= attributedText4;
![](http://static.blog.csdn.net/images/save_snippets.png)
- 顶
- 0
NSAttributeString创建各种文字效果的更多相关文章
- CSS Gradient文字效果
你想创建的标题没有渲染和Photoshop每个标题吗?这里是一个简单的CSS技巧向您展示如何创建渐变文字效果,PNG图像(纯CSS,没有Javascript或Flash).你所需要的是一个空的< ...
- JAVA 跑马灯文字效果
JAVA跑马灯文字效果的实现: 1. 首先创建一个继承JFrame类的HorseRaceLightTextFrame窗体类,代码如下: package com.example.horseracelig ...
- css文字效果(文字剪贴蒙版,text-shodow的应用,文字排版等…)
.katex { display: inline-block; text-align: initial; } .katex { font-family: Consolas, Inconsolata, ...
- 第95天:CSS3 边框、背景和文字效果
1.CSS3边框: border-radius:CSS3圆角边框.在 CSS2 中添加圆角矩形需要技巧,我们必须为每个圆角使用不同的图片,在 CSS3 中,创建圆角是非常容易的,在 CSS3 中,bo ...
- css鼠标滑过出现文字效果
模仿淘宝上鼠标移动到商品图片时,出现的文字效果. 1.效果图 鼠标移动到粉红色的区域,则出现黄色部分. 2.代码 <!DOCTYPE ...
- Qt qml 模拟iphone slide to unlock 的聚光动画文字效果
模拟iphone slide to unlock 的聚光动画文字效果 /底层放淡文字 /前景放高亮文字+半透明遮罩 /动画移动遮罩 Author: surfsky.cnblogs.c ...
- Progress.js – 为页面上的任意对象创建进度条效果
Progress.js 是一个 JavaScript 和 CSS3 的库,它帮助开发人员为网页上的每个对象创建和管理进度条效果.你可以设计自己的模板,进度条或者干脆定制. 您可以使用 Progress ...
- 【转】使用jquery animate创建平滑滚动效果
这篇文章主要介绍了使用jquery animate创建平滑滚动效果,效果可以滚动到顶部.到底部或页面中指定地方,生要的是非常平滑,很舒服,需要的朋友可以参考下 滚动到顶部: $('.scroll_to ...
- as3.0:文字 效果
//文字描边效果var tf1 = _root.createTextField("tf1", _root.getNextHighestDepth(), 10, 10, 0, 0); ...
随机推荐
- PhoneGap/Cordova Android应用签名公布注意事项
今天最终要公布Android HybirdApp了,安装曾经做原生应用的流程公布签名Apk,没想到立即遇到了几个问题.如今把它们的解决的方法整理下来. export signed Apk 遇到以下错误 ...
- 多重背包模板 51Nod 1086
有N种物品,每种物品的数量为C1,C2......Cn.从中任选若干件放在容量为W的背包里,每种物品的体积为W1,W2......Wn(Wi为整数),与之相对应的价值为P1,P2......Pn(Pi ...
- 原生js中获取this与鼠标对象以及vue中默认的鼠标对象参数
1.通过原生js获取this对象 <!DOCTYPE html> <html> <head> <meta charset="utf-8" ...
- 【Codeforces Round #426 (Div. 2) B】The Festive Evening
[Link]:http://codeforces.com/contest/834/problem/B [Description] [Solution] 模拟水题; 注意一个字母单个出现的时候,结束和开 ...
- SQL优化工具SQLAdvisor使用(转)
一.简介 在数据库运维过程中,优化SQL是业务团队与DBA团队的日常任务.例行SQL优化,不仅可以提升程序性能,还能够降低线上故障的概率. 目前常用的SQL优化方式包括但不限于:业务层优化.SQL逻辑 ...
- Intellij IDEA中修改项目名称
如下图红色标识所示: 修改方法见下图:
- android图像处理系列之五--给图片添加边框(中)
前面一篇讲到给图片加边框的方式,只能给图片加一些有规则的边框,如果想加一些比较精美的效果,就有点麻烦了.下面就给出解决这个问题的思路. 思路是:一些比较精美的花边图片我们是很难用代码控制,就目前本人水 ...
- 矩阵乘法java代码实现
矩阵只有当左边矩阵的列数等于右边矩阵的行数时,它们才可以相乘, 乘积矩阵的行数等于左边矩阵的行数,乘积矩阵的列数等于右边矩阵的列数 即A矩阵m*n,B矩阵n*p,C矩阵m*p: package exa ...
- SQL数值转字符串保留指定小数位
IF EXISTS ( SELECT * FROM sysobjects WHERE xtype = 'fn' AND name = 'fn_NumberFormat' ) BEGIN DROP FU ...
- Codefroces Round#427 div2
A. Key races time limit per test 1 second memory limit per test 256 megabytes input standard input o ...