简体   繁体   中英

How do you have two fonts in one UITextView (Xcode)?

我想在一个UITextView中制作两个字体styes,我该怎么做?

From the class reference :

This class does not support multiple styles for text. The font, color, and text alignment attributes you specify always apply to the entire contents of the text view. To display more complex styling in your application, you need to use a UIWebView object and render your content using HTML.

You cannot have two on the same page because it is not supported. Just use a webview and an HTML file

You can know use this by using the attributedText property of UITextView. This is available under iOS 6

UITextView supports just a single font, but there's a different topic on something similar: Can I use multiple font style in UITextView?

If the text you want to draw is simple, I'd suggest subclassing UITextView or UIView, overwriting the drawRect function and work with some extra variables of your own. This only works if you have a very predictable system to the fonts though.

Another option is using multiple labels, which would probably need an ever more predictable setup.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM