iOS富文本和html字符串互转
来源:互联网 发布:开淘宝店要花钱吗 编辑:程序博客网 时间:2024/05/24 04:21
//html字符串转换为富文本NSString *htmlStr = @"我的<span style='color:red'>aafaf微</span>我的<span style='color:red'>aafaf微</span>"; NSAttributedString *att = [[NSAttributedString alloc] initWithData:[htmlStr dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil]; //富文本转换为html(最后相当于整个网页代码,会有css等) NSDictionary *dic = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute:@(NSUnicodeStringEncoding)}; NSData *data = [att dataFromRange:NSMakeRange(0, att.length) documentAttributes:dic error:nil]; NSString *str = [[NSString alloc] initWithData:data encoding:NSUnicodeStringEncoding];
0 0
- iOS富文本和html字符串互转
- iOS UIlabel怎么加载html字符串 富文本的用法
- iOS 富文本加载 HTML
- V5富文本和HTML
- iOS中字符串和富文本相互转换
- iOS label加载html富文本内容
- iOS富文本字符串AttributedString详解
- iOS富文本字符串AttributedString详解
- iOS-[NSAttributedString]设置富文本和计算富文本高度
- iOS 富文本~设置字体大小和颜色
- 解析html富文本
- 富文本(属性字符串)
- Android富文本字符串
- Android富文本字符串
- iOS UILabel 显示带有html标签的富文本内容
- ios 富文本编辑器
- iOS之富文本
- iOS之富文本
- 复习
- React Native之导航器Navigator实现导航功能(一)
- React Native学习笔记
- 两种常见挂载Jenkins slave节点的方法
- ARM中常用的汇编指令集
- iOS富文本和html字符串互转
- Flex 布局
- Android中moveTo、lineTo、quadTo、cubicTo、arcTo详解(实例)
- 数据库
- 求圆环面积
- ssh远程连接docker中的container
- javaSwing布局管理器之TableLayout
- Ubuntu 16.04下面安装grub-customizer来切换ubuntu+win7双系统开机启动顺序
- CF 55D Beautiful numbers (数位DP入门)