normalFontheightWithWidth方法如下:(供参考)
附超链接的属性:
加油吧!
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 30, 20, 114)]
textView.backgroundColor = [UIColor redColor]
[self.view addSubview:textView]
NSString *htmlString = @"<h1>Header</h1><h2>Subheader</h2><p>Some <em>text</em></p>![]( https://img-blog.csdnimg.cn/20190927151043371.png )"
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData: [htmlString dataUsingEncoding:NSUnicodeStringEncoding] options: @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes: nil error: nil]
textView.attributedText = attributedString
UITextView*textView = [[UITextViewalloc]initWithFrame:CGRectMake(20,30,100,199)]
textView.backgroundColor = [UIColor redColor]
[self.view addSubview:textView]
NSString *htmlString = @"<h1>header</h1><h2>Subheader</h2><p>Some<em>text</em></p>![](http://blogs.babble.com/famecrawler/files/2010/11/mickey_mouse-1097.jpg)"
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData: [htmlString dataUsingEncoding:NSUnicodeStringEncoding] options: @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes: nil error: nil]
textView.attributedText = attributedString
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)