7使用HTML字符串作为NSAttributedString并设

7使用HTML字符串作为NSAttributedString并设

本文介绍了iOS 7使用HTML字符串作为NSAttributedString并设置字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITextView,我正在尝试显示一些HTML格式的属性文本。它使用内联粗体和斜体等内容。客户端现在希望更改此字体。但是,每当我更改字体时,它似乎忽略任何HTML格式。是否有任何方法可以在保留其他格式属性的同时更改字体,例如粗体斜体化?

I have a UITextView in which I'm trying to display some attributed text which comes in the form of HTML. It uses things like inline bolding and italicizing. The client now wants the font on this to change. However, whenever I change the font, it seems to disregard any of the HTML formatting. Is there any way to change the font while retaining the other formatting attributes, like bolding an italicizing?

推荐答案

我的方式让它工作的是在我的字符串前加上< span style = \font-family:Avenir; font-size:12 \>%@< / span>

The way I was able to get it to work was to prepend my string with <span style=\"font-family: Avenir; font-size: 12\">%@</span>

这篇关于iOS 7使用HTML字符串作为NSAttributedString并设置字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 07:37