Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何在UILabel中使用多个不同的UIFonts?_Objective C_Ios - Fatal编程技术网

Objective c 如何在UILabel中使用多个不同的UIFonts?

Objective c 如何在UILabel中使用多个不同的UIFonts?,objective-c,ios,Objective C,Ios,我的UIView中有一个UILabel。我的标签文本是动态的:它是一个web服务调用,返回我将放入标签中的文本。以下是标签内容的示例: "this is an example of my text/nthis is the second line". 我想把第一行放在一种特定的字体中(例如Helvetica Bold 12px),第二行放在另一种字体中(例如Helvetica 15px)。我怎么能做到? 感谢您的回答。老实说,我建议您使用两个单独的UILabel实例,通过[string co

我的UIView中有一个UILabel。我的标签文本是动态的:它是一个web服务调用,返回我将放入标签中的文本。以下是标签内容的示例:

"this is an example of my text/nthis is the second line". 
我想把第一行放在一种特定的字体中(例如Helvetica Bold 12px),第二行放在另一种字体中(例如Helvetica 15px)。我怎么能做到?
感谢您的回答。

老实说,我建议您使用两个单独的UILabel实例,通过
[string components separatedbystring:@“\n”]
获取文本和数组,然后将对象放在第一个实例的索引0处,如果您有第二个对象,将它放在第二个标签中。

您可以使用静态的
UIWebView
并简单地将文本包装成HTML+CSS。这将比在代码中进行所有布局容易得多。

也许您要查找的是NSAttributedString。
这里有一个例子:

谢谢,我认为所有提供给我的解决方案都很好。