局部富文本
2016-06-24 16:50
295 查看
UILabel *testLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 100, 320, 30)];
testLabel.backgroundColor = [UIColor lightGrayColor];
testLabel.textAlignment = NSTextAlignmentCenter;
NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"今天天气不错呀"];
[AttributedStr addAttribute:NSFontAttributeName
value:[UIFont systemFontOfSize:16.0]
range:NSMakeRange(2, 2)];
[AttributedStr addAttribute:NSForegroundColorAttributeName
value:[UIColor redColor]
range:NSMakeRange(2, 2)];
testLabel.attributedText = AttributedStr;
[self.view addSubview:testLabel];
testLabel.backgroundColor = [UIColor lightGrayColor];
testLabel.textAlignment = NSTextAlignmentCenter;
NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"今天天气不错呀"];
[AttributedStr addAttribute:NSFontAttributeName
value:[UIFont systemFontOfSize:16.0]
range:NSMakeRange(2, 2)];
[AttributedStr addAttribute:NSForegroundColorAttributeName
value:[UIColor redColor]
range:NSMakeRange(2, 2)];
testLabel.attributedText = AttributedStr;
[self.view addSubview:testLabel];
相关文章推荐
- C语言 单引号 双引号问题
- 14.4.3.5 Configuring InnoDB Buffer Pool Flushing 配置InnoDB Buffer Pool 刷新:
- 14.4.3.5 Configuring InnoDB Buffer Pool Flushing 配置InnoDB Buffer Pool 刷新:
- 下拉菜单包含搜索框-searchableSelect
- RelativeLayout 常用属性介绍
- 设计模式学习-工厂模式/桥接模式
- yum 指定版本安装
- hive udf使用
- 2016-6-24 无刷新提交
- 正态分布
- CSAPP Cache实验
- Java - 基本类的使用(Map集合类)
- Ant网址
- EventBus 3.0 使用
- 接口缓存不能放置在静态的数据结构存储
- java之虚拟机详解
- nodejs第一个hello world代码
- Elasticsearch java API (10)Multi Get API
- 硬件创业者们,如何避免掉到供应链的大坑里爬不出来
- 将用户在jsp表单输入的信息赋给JavaBean