iOS开发实现Label中多颜色多字体
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(8, 100, 300, 30)];
label.textColor = wordGaryColor; //未专门设置的字体颜色
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"公司简介:发挥收到后即可圣诞节快发吧士大夫深刻的房价高速度开放和山东矿机山东科技楼粉红是大家分工"];
[str addAttribute:NSForegroundColorAttributeName value:commonColor range:NSMakeRange(0,5)];
[str addAttribute:
NSForegroundColorAttributeName
value:[UIColor redColor] range:
NSMakeRange
(6,12)];
[str addAttribute:
NSForegroundColorAttributeName
value:[UIColor greenColor] range:
NSMakeRange
(19,6)];
[str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:19] range:NSMakeRange(0, 5)];
[str addAttribute:
NSFontAttributeName
value:[UIFont fontWithName:@
"HelveticaNeue-Bold"
size:30.0] range:
NSMakeRange
(6, 12)];
[str addAttribute:
NSFontAttributeName
value:[UIFont fontWithName:@
"Courier-BoldOblique"
size:30.0] range:
NSMakeRange
(19, 6)];
label.attributedText = str;
[self.view addSubview:label];
iOS开发实现Label中多颜色多字体的更多相关文章
- iOS开发之动画中的时间(概况)
一.引言 在iOS开发中使用动画时,可以通过设置动画的duration.speed.begintime.offset属性,来设置动画的时长.速度.起始时间及起始偏移. 用一个简单的例子来说明各个参数的 ...
- IOS开发-UI学习-UIFont,字体设置及批量创建控件
在IOS 中,使用[UIFont familyNames]这个方法获取72种系统字体. 使用[UIFont fontWithName:@"Zapfino" size:18]这个方法 ...
- iOS改变UINavigationBar导航条标题颜色和字体
转自:http://www.2cto.com/kf/201311/260409.html iOS 5 以后 UINavigationController 可以 改变UINavigationBar导航条 ...
- iOS开发-从16进制颜色中获取UIColor
目前iOS中设置UIColor只能使用其枚举值.RGB等方法,不能直接将常用的16进制颜色值直接转为UIColor对象,所以写了点代码,将16进制颜色值转为UIColor. 代码如下, //头文件#i ...
- 把所有界面的状态栏字体颜色设置为白色--iOS开发系列---项目中成长的知识一
第一步: 在info.plist中 View controller-based status bar appearance这个属性设置为 View controller-based status ba ...
- iOS开发改变字符串中指定字符颜色,大小等等
NSString *strJTGZ = [NSString stringWithFormat:@"交通管制%d处 ",[jtgz intValue]]; NSMutableAttr ...
- (转)iOS 开发,工程中混合使用 ARC 和非ARC
[前提知识] ARC:Automatic Reference Counting,自动引用计数 在开发 iOS 3 以及之前的版本的项目时我们要自己负责使用引用计数来管理内存,比如要手动 retain. ...
- iOS 开发,工程中混合使用 ARC 和非ARC(转)
[前提知识] ARC:Automatic Reference Counting,自动引用计数 在开发 iOS 3 以及之前的版本的项目时我们要自己负责使用引用计数来管理内存,比如要手动 retain. ...
- iOS开发-修改UITableViewCell中image和title的位置和大小
最近在开发中遇到需要Cell中imageView和textLable位置和大小的情况,设计希望得到的结果如下图所示: 而TableViewCell默认样式,image是靠紧左边的,并且image和ti ...
随机推荐
- Cloudsim 3.0在myclipse下的安装过程
(1)下载cloudsim 3.0: http://code.google.com/p/cloudsim/downloads/list (2)下载flanaga.jar包 下载地址:http://w ...
- andorid 自定义view属性declare-styleable
1. reference:参考某一资源ID. (1)属性定义: <declare-styleable name = "名称"> <attr name = &quo ...
- Java 多态,重载,重写
1.多态(polymorphism): 多态是指程序中定义的引用变量所指向的具体类型和通过该引用变量发出的方法调用在编程时并不确定,而是在程序运行期间才确定,即一个引用变量倒底会指向哪个类的实例对象, ...
- android代码实现免提功能
初始化AudioManager: private static AudioManager audioManager; 实现免提功能方法 protected void setSpeekModle() { ...
- plat模板修改记录
每个栏目显示文章数 homepage.hph 94行 $loop = new WP_Query('post_type=post&showposts=6&category_name=xi ...
- Android Studio 提示Error running app: No Android facet found for app
错误解决办法如下: 可以通过以下几个步骤解决该问题: 1) 点击菜单File -> 选择Project Structure, 或使用快捷键 (Ctrl+Alt+Shift+S) 打开”Proje ...
- sphinx分域搜索【不】需要在conf文件中使用sql_field_string
请看sql_field_string的文档说明: # combined field plus attribute declaration (from a single column) # stores ...
- windows2012 r2 提高网速方法
2012 升级到 r2 微软官方地址:(感谢Monkey威武)Datacenter Preview:简体中文:http://care.dlservice.microsoft.com/dl/downlo ...
- php的header函数之设置content-type
//定义编码 header( 'Content-Type:text/html;charset=utf-8 '); //Atom header('Content-type: application/at ...
- elisp
cons cell? 构建内存对象! 通过寄存器的基地址car和偏移地址cdr来--寻址内存对象,我是这样理解的. http://wiki.dourok.info/doku.php/%E5%B7%A5 ...