在Interface Builder中更改UITextView中单个单词的字体 [英] Change font of individual words in UITextView in Interface Builder

查看:76
本文介绍了在Interface Builder中更改UITextView中单个单词的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果这个问题听起来很愚蠢,它是如此简单,请允许我深表歉意.我最近在另一个程序上苦苦挣扎了3个小时,这个问题非常简单,以至于互联网上还没有人遇到这个问题.

Let me apologize in advanced if this question sounds stupid it's so incredibly simple. I struggled for 3 hours with another program recently with a problem that was so simple that no one on the internet had even had the problem yet.

无论如何,我想做的是将一个UITextView添加到界面"构建器中的程序中,复制并粘贴一段文本,然后将适当的单词加粗,将适当的单词设为斜体.就这样.我知道,如果我选择该字段并按cmd t,则可以更改整个块的文本,但是,我似乎无法找到仅更改某些单词的方法.我知道这是有可能的,因为我的iPod Touch上确实有可以完全做到这一点的应用程序.

Anyhow, what I want to do is add a UITextView to my program in Interface builder, copy and paste a block of text, then make the appropriate words bold, and the appropriate words italic. That's all. I know that if I select the field and hit cmd t, I can change the text of the entire block, however, I can't seem to find a way to only change certain words. I know it is possible because I have apps on my iPod Touch that do EXACTLY this.

无论如何,我希望有一种方法可以在界面生成器中执行此操作,因为以编程方式(在我正在研究的特定项目上)可以很快变得非常混乱.

Anyhow, I'm hoping there's a way to do this in interface builder since doing it programatically (on the particular project I'm working on) could get very messy very fast.

预先感谢您,如果我让您满意,请原谅我,因为我对所有这些苹果东西都很陌生...

Thank you in advance, and forgive me if I make you rofl or something since I'm so new to all this apple stuff...

推荐答案

这不是一个愚蠢的问题:UITextView仅支持一种字体,样式,大小和颜色.

It's not a stupid question: UITextViews only support a single font, style, size, and color.

最简单的解决方案(尽管不一定是最好的)是在HTML样式的文本中使用UIWebView. Web视图似乎要花很多时间来处理这样的小事情,而且可能确实如此.

The easiest solution -- though it may or may not be the best -- is to use a UIWebView with HTML-styled text in it. A web view seems like a lot of overhead for such a little thing, and it probably is.

尽管如此,直到8个月前,它才是唯一的解决方案(嗯,我相信您以前也可以使用Quartz/Core Graphics,但我很少看到它),即使那样,它也只能在iPad上使用.使用iOS 3.2或更高版本,您可以在所有iOS设备上使用Core Text.不幸的是,有很多东西要学,但这绝对是可行的.

Nonetheless, until 8 months ago it was just about the only solution (well, I believe you could also use Quartz/Core Graphics previously, but I rarely saw it), and even then it was only on the iPad. With iOS 3.2 or greater you can use Core Text on all iOS devices. Unfortunately there's quite a lot to learn, but it's definitely doable.

我实际上不知道Core Text的开销与UIWebView相比如何.

I actually don't know how the overhead of Core Text compares to a UIWebView.

这篇关于在Interface Builder中更改UITextView中单个单词的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆