NSMutableAttributedString range 的意思
2016-05-24 00:00
148 查看
摘要: NSMutableAttributedString range 的意思 NSRange contentRange = {8,6};//8 表示从第九位开始,6表示汉字的个数
NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:@"bgbg"];
[str addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)[UIColor yellowColor].CGColor range:NSMakeRange(0, 2)];
UILabel *label = [[UILabel alloc]init];
label.frame = CGRectMake(0, 100, 300, 30); NSMutableAttributedString * content = [[NSMutableAttributedString alloc]initWithString:@"我已阅读并同意《用户服务协议》"];
NSRange contentRange = {8,6};//8 表示从第九位开始,6表示汉字的个数
[content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
[content addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(7, [content length]-7)];
[content addAttribute:NSStrokeWidthAttributeName value:[NSNumber numberWithInt:5] range:contentRange];
[content addAttribute:NSForegroundColorAttributeName value:[UIColor grayColor] range:NSMakeRange(0, 7)];
[content addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0f] range:NSMakeRange(0, content.length)];
// [_protocolButton setAttributedTitle:content forState:UIControlStateNormal];
label.attributedText = content;
// label.backgroundColor = [UIColor lightGrayColor];
[self.view addSubview:label];
NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:@"bgbg"];
[str addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)[UIColor yellowColor].CGColor range:NSMakeRange(0, 2)];
UILabel *label = [[UILabel alloc]init];
label.frame = CGRectMake(0, 100, 300, 30); NSMutableAttributedString * content = [[NSMutableAttributedString alloc]initWithString:@"我已阅读并同意《用户服务协议》"];
NSRange contentRange = {8,6};//8 表示从第九位开始,6表示汉字的个数
[content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
[content addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(7, [content length]-7)];
[content addAttribute:NSStrokeWidthAttributeName value:[NSNumber numberWithInt:5] range:contentRange];
[content addAttribute:NSForegroundColorAttributeName value:[UIColor grayColor] range:NSMakeRange(0, 7)];
[content addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0f] range:NSMakeRange(0, content.length)];
// [_protocolButton setAttributedTitle:content forState:UIControlStateNormal];
label.attributedText = content;
// label.backgroundColor = [UIColor lightGrayColor];
[self.view addSubview:label];
相关文章推荐
- Ubuntu命令行修改网络配置方法
- iOS蓝牙开发(一)蓝牙相关基础知识
- ios宏的使用和技巧
- ios蓝牙开发(二)ios连接外设的代码实现
- ios蓝牙开发(三)app作为外设被连接的实现
- 对Java线程池的理解
- Android系统为什么要分层实现?
- Linux Enlarge the LV
- 个人博客选择网站空间的六个技巧
- 人气有所回升,反弹看量能
- 50个jQuery代码段帮你成为更出色的JS开发者
- jquery实现验证码发送以及验证码的有效时间30分钟实现方式
- NPOI导出数据到Excel
- ashx文件获取$.ajax()方法发送的数据
- Newtonsoft.Json(Json.Net)学习笔记
- gitblit搭建git服务器
- 不允许保存更改。您所做的更改要求删除并重新创建一下表。您对无法重新创建的表进行了更改或启用了“阻止保存要求重新创建表的更改”选项
- Http请求中Content-Type讲解以及在Spring MVC中的应用
- 基础连接已经关闭: 未能为 SSL/TLS 安全通道建立信任关系
- odi接口抽取数据报错提示Create Unique Index on flow table创建唯一索引失败解决方法