#import "AppDelegate.h"

 @interface AppDelegate ()

 @end

 @implementation AppDelegate

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];
// 设置多属性字符串
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Using NSAttributed String"];
// 设置蓝色字体,范围(0, 5),其中空格也算一个占位符
[str addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(, )];
// 设置红色字体,范围(6, 12),其中空格也算一个占位符
[str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(, )];
// 设置红色字体,范围(13, 6),其中空格也算一个占位符
[str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(, )]; label.attributedText = str; [self.window addSubview:label];
[self.window makeKeyAndVisible];
return YES;
} @end

在一个Label上设置多种颜色字体的更多相关文章

  1. android 一个TextView设置多种颜色

    时候一个文本框为了强调内容需要显示不同颜色,用以下代码可以轻松实现 方法一:(适用于颜色变化多的情况)   //为文本框设置多种颜色 textView=(TextView)findViewById(R ...

  2. iOS一段文字设置多种颜色格式

    调用 [self fuwenbenLabel:contentLabel FontNumber:[UIFont systemFontOfSize:] AndRange:NSMakeRange(, ) A ...

  3. iOS在一个label中显示不同颜色的字体

    UILabel *Label = [[UILabel alloc] initWithFrame:CGRectMake(20, 300, 300, 30)]; NSMutableAttributedSt ...

  4. idea软件上设置爱彼迎字体

  5. UILable:显示多种颜色的方法

    借用别人封装好的类库,用来显示同一个UILable上的多种颜色的字. 类库可以直接在次博客中下载,下载后别忘留言哦. 类库使用:主要用了CoreText里面的东西,所以在使用类库之前需要引用CoreT ...

  6. asp.net在配置文件里设置多种编码方式的研究

    我们在做asp.net的程序时,在根目录下肯定会有一个web.config的文件, 有点开发经验的可能都知道,它是配置程序的全局信息的地方, 当然了,也可以在这里做更多的事情,下面我们来研究一下 ,如 ...

  7. 设置label的文字,一行多种颜色

    调用 [self fuwenbenLabel:contentLabel FontNumber:[UIFont systemFontOfSize:] AndRange:NSMakeRange(, ) A ...

  8. NSString -- UILabel中字体有多种颜色,字符串自动计算高度/换行

    一:UILabel中字体有多种颜色 UILabel *label = [[UILabel alloc] init]; label.frame = CGRectMake(, , , ); label.b ...

  9. TextView的一些高级应用(自定义字体、显示多种颜色、添加阴影)

    1.    自定义字体可以使用setTypeface(Typeface)方法来设置文本框内文本的字体,而android的Typeface又使用TTF字体文件来设置字体所以,我们可以在程序中放入TTF字 ...

随机推荐

  1. BKDRhash实现

    参考了一些有关于哈希算法的博客,里面都有提到BKDR哈希算法,在博客:各种字符串Hash函数中有对各种hash算法进行测试,测试关于哈希冲突,以及散列的质量,得到的结果可以参考以上博文. BKDRha ...

  2. SVN 树冲突的解决方法(Ubuntu 环境)

    今天在 服务器上(Ubuntu) svn up 更新的时候,出现了 SVN 树冲突 root@futongdai:~# cd /home/wwwroot/newcrm.ofim.com/ root@f ...

  3. linux python版本升级

    升级python版本的时候千万不能卸载python 2.6,再安装python2.7,这样会有无穷无尽的麻烦,保守的方式 是直接安装python2.7的源码包,也就是python两个版本共存.(因为C ...

  4. markdown 书写表格

    Tables Are Cool col 3 is right-aligned $1600 col 2 is centered $12 zebra stripes are neat $1 Refs ma ...

  5. Nobel Lecture, December 12, 1929 Thermionic phenomena and the laws which govern them

    http://www.nobelprize.org/nobel_prizes/physics/laureates/1928/richardson-lecture.pdf OWEN W. RICHARD ...

  6. shell常用代码

    grep -lr 'hello' /usr/share/* #在/usr/share目录下查找包含hello的字符串 NOW_DATE=`date "+%Y%m%d%H%M%S"` ...

  7. XPS to Blender 2.7x

    XPS to Blender 2.7x(Blender internal the easy way) Things we are gonna need are Blender 2.7x www.ble ...

  8. Bootstrap 标签页和工具提示插件

    一.标签页 标签页也就是通常所说的选项卡功能. //基本用法 <ul class="nav nav-tabs"> <li class="active&q ...

  9. ubuntu navicat

    接下来是从网络上下载Chrome对应是版本的包,小编的系统是64位的,因此,执行:wget https://dl.google.com/linux/direct/google-chrome-stabl ...

  10. JavaScript判断字符串的字符长度(中文占两个字符)

    判断方法 //判断字符串中的字符 中文算两个字符 function chkstrlen(str) { ; ; i < str.length; i++) { ) //如果是汉字,则字符串长度加2 ...