iOS-加载html字符串
NSMutableAttributedString * attrString =[[NSMutableAttributedString alloc] initWithData:[resultModel.tips dataUsingEncoding:NSUnicodeStringEncoding]options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType}documentAttributes:nil error:nil];
[attrString addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:]} range:NSMakeRange(, attrString.length)];
self.descLabel.attributedText = attrString;
算高度
NSMutableAttributedString *htmlString =[[NSMutableAttributedString alloc] initWithData:[str dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSCharacterEncodingDocumentAttribute:[NSNumber numberWithInt:NSUTF8StringEncoding]}documentAttributes:NULL error:nil];
[htmlString addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:]} range:NSMakeRange(, htmlString.length)];
CGSize textSize = [htmlString boundingRectWithSize:(CGSize){ScreenWidth - , CGFLOAT_MAX}options:NSStringDrawingUsesLineFragmentOrigin
context:nil].size;
return textSize.height ;
iOS-加载html字符串的更多相关文章
- iOS UIlabel怎么加载html字符串 富文本的用法
要加载html字符串,用人说,直接用webView啊!但是,有时候我们只需要显示2行文字,如此少的内容却要在复杂的UI排版中加入一个占用资源较多的webview,得不偿失.这里要说的是,我们其实可以用 ...
- js便签笔记(8)——js加载XML字符串或文件
1. 加载XML文件 方法1:ajax方式.代码如下: var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObje ...
- javascript加载XML字符串或文件
1. 加载XML文件 方法1:ajax方式.代码如下: var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObje ...
- Android 如何使用 WebView 加载 HTML 字符串和处理转译字符
Android 如何使用 WebView 加载 HTML 字符串和处理转译字符 css bug 在 WebView 中编译 Web 应用 如果您希望在客户端应用中提供 Web 应用(或只是网页),则可 ...
- iOS加载程序视图的方式
The UIViewController class provides built-in support for loading a view controller's views whenever ...
- iOS 加载图片选择imageNamed 方法还是 imageWithContentsOfFile?
Apple官方的文档为生成一个UIImage对象提供了两种方法: 1. imageNamed,其参数为图片的名字: 2. imageWithContentsOfFile,其参数也是图片文件的路径. ...
- iOS加载HTML, CSS代码
NSString *strHTML = @"<div style=\"text-align:center;\"><img src=\"/Upl ...
- 10、 iOS 加载图片选择imageNamed 方法还是 imageWithContentsOfFile
Apple官方的文档为生成一个UIImage对象提供了两种方法: 1. imageNamed,其参数为图片的名字: 2. imageWithContentsOfFile,其参数是图片文件的路径. 两种 ...
- iOS 加载本地 HTML 文件 CSS 样式图片无效果
在开发的过程中,有时候需要加载一些 HTML 页面,对于不太复杂的界面,基本上都可以放到本地用 UIWebview 来加载,但是在开发过程中会碰到 UIWebview 加载出来的 HTML 页面没有图 ...
- webView加载url,加载指定字符串
//加载url-(void)addWebView{ UIWebView * webView = [[UIWebView alloc] initWithFrame:CGRectMake(, , zScr ...
随机推荐
- Elasticsearch 6 重要参数配置
采用zip或tar.gz的二进制包方式安装的ES,需要配置一系列参数,其中重要参数配置如下: 一. ElasticSearch参数配置 1. data和logs路径配置 如果使用.zip或.tar.g ...
- fedora/centos下gcc编译出现gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory
fedora/centos下gcc编译出现gcc: error trying to exec 'cc1plus': execvp: No such file or directory解决办法 翻译自: ...
- 北京Uber优步司机奖励政策(11月23日~11月29日)
用户组:人民优步"关羽组"(适用于11月23日-11月29日)奖励政策: 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最 ...
- 成都Uber优步司机奖励政策(1月19日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- spring boot 数据库连接
server: port: 8080 spring: datasource: url: jdbc:mysql://localhost:3306/jdjk?serverTimezone=Asia/Sha ...
- 安卓app连接CC2541-手机休眠后唤醒,通信不再成功
1. 现在遇到的问题,手机进入休眠状态后唤醒,APP软件和CC2541的通信不正常了,但是CC2541依然检测到时连接状态.如何解决这个问题?手机唤醒之后会重新创建活动? 2.Wakelock 锁机制 ...
- 角色 RESOURCE、CONNECT、DBA具有的权限
角色 RESOURCE.CONNECT.DBA具有的权限 select grantee,privilege from dba_sys_privs where grantee='RESOURCE' or ...
- Mate20兼容性如何?WeTest带你抢先测!
自从九月份 iPhone XS 系列发布后,WeTest团队迅速入库了iPhone XS和iPhone XR设备,十月份国内巨头华为也重磅推出了一款“Mate 20”设备,让下半年的国内手机市场又热闹 ...
- 「日常训练」Woodcutters(Codeforces Round 303 Div.2 C)
这题惨遭被卡..卡了一个小时,太真实了. 题意与分析 (Codeforces 545C) 题意:给定\(n\)棵树,在\(x\)位置,高为\(h\),然后可以左倒右倒,然后倒下去会占据\([x-h,x ...
- jmeter "you cannot switch bacause data cannot be converted to target Tab data,empty data to switch"报错
jmeter "you cannot switch bacause data cannot be converted to target Tab data,empty data to swi ...