如何在同一个UITextField或UITextView中保留2种不同的字体? [英] How to keep 2 different fonts within the same UITextField or UITextView?
本文介绍了如何在同一个UITextField或UITextView中保留2种不同的字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在同一个 UITextField
和 UITextView
中设置2种不同的字体。怎么做?
I want to set 2 different fonts within the same UITextField
and UITextView
. How to do it?
推荐答案
它有点工作 - 你需要使用核心文本和 NSAttributedString 来做到这一点。
Its a bit of work - you'll need to use Core Text and NSAttributedString to do this.
有有很多教程和例子,虽然我建议使用别人已经制作的UILabel子类,例如:
There are plenty of tutorials and examples, although I'd suggest using someone else's already-made UILabel subclass such as:
和
因为这些通常有一些方便的方法来使处理变得更容易。
As these usually have some convenience methods to make handling a lot easier.
这篇关于如何在同一个UITextField或UITextView中保留2种不同的字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文