UILabel加载HTML文本和字体颜色修改
来源:互联网 发布:乾坤决策眼指标源码 编辑:程序博客网 时间:2024/05/23 13:16
1. 加载HTML文本
NSString *html = @"";
NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[html dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSFontAttributeName:[UIFont systemFontOfSize:15] } documentAttributes:nil error:nil];
label.attributedText = attrStr;
2. 字体颜色修改
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Using NSAttributed String"];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] 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 fontWithName:@"Arial-BoldItalicMT" size:30.0] 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;
- UILabel加载HTML文本和字体颜色修改
- UILabel加载html文本
- UILabel字体颜色和大小
- UILabel设置多种字体、颜色(文本中字体不同颜色)
- UGUI文本字体颜色和大小等代码修改
- 利用UILabel、UITextView加载html文本
- 利用UILabel、UITextView加载html文本
- UILabel显示不同的颜色和字体
- UILabel 显示多种字体和颜色
- UILabel显示不同的字体和颜色
- UILabel 分段改变文字颜色和字体
- UILabel显示不同的字体和颜色
- UILabel 添加下划线,改变字体颜色,NSMutableAttributedString实现富文本
- MFC修改文本框和字体颜色 加载图片
- CSS,文本,字体和颜色
- Linux文本界面字体颜色修改
- HTML 文本的颜色 段落的颜色和字体大小以及字体类型
- 【HTML 字体颜色和样式】
- 外行学html5 - emmet 使用
- HDU 1255 ( 覆盖的面积 ) 矩形面积并
- NIOSII中的LWIP协议栈中的FD_ZERO,FD_SET,FD_ISSET
- EC纠删码(Erasure Code)校验码算法相比传统RAID5有哪些优势?
- iOS 中 coredata 的使用步骤
- UILabel加载HTML文本和字体颜色修改
- <NetCat> nc命令详解
- android studio 用 Live Templates 自动生成switch、try、for、if
- Java通信过程的中文乱码的解决
- sql修改以及添加表字段
- MySQL学习笔记--主从复制故障重置操作
- FileStream常用的属性与方法总结
- BackgroundWorker 的简单使用
- 细说五层网站架构