AttributedString
2016-06-22 11:00
169 查看
AttributedString的初始化
通常初始化AttributedString的方式有两种:
NSString *str = @"Hello, the Word!"; NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString: str]; UILabel *textLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 64, 300, 50)]; textLabel1.numberOfLines = 0; textLabel1.textAlignment = NSTextAlignmentLeft; [self.view addSubview:textLabel1]; NSString *str = @"textLabel1: Hello, the Word!"; NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:str]; [attribute addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"zapfino" size:15.0] range:NSMakeRange(0, str.length)]; [attribute addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(12, 4)]; [attribute addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(16, 5)]; textLabel1.attributedText = attribute;
相关文章推荐
- 秒杀核心设计(减库存部分)-防超卖与高并发
- Android JNI学习笔记2
- 浅析JavaScript中命名空间namespace模式
- Python类方法、静态方法与实例方法
- GIT 从入门到放弃大整理
- 构建之法阅读笔记06
- DB2 时间操作
- Xcode 配置 路径
- POJ 1661 Help Jimmy
- c3p0连接配置
- kmp单片自动机
- iOS 开发之Target-action模式
- Oracle查看耗资源SQL
- swift Alamofire+ObjectMapper——swift(学习九)
- ECSHOP通过改变模板路径制作手机站
- Tachyon源码结构分析(四)
- ROS下使用摄像头
- win7 solr6.1.0+jdk1.8
- *p++/(*p)++/*(p++)的区别
- Linux 调优方案, 修改最大连接数(ulimit命令)