在 iPhone 中自定义文本视图
在我的应用程序中,我有一个包含大量内容的文本视图,其中为用户显示了一些帮助提示。在该文本视图中,我必须将一些标题加粗。我可以在界面生成器中设置它吗?有人知道吗?是否可以任何其他 uiobjects,如 uilabel 或其他东西?我尝试使用图像视图,但不清楚。
In my application i have a text view with a large content which shows some help tips for the user.In that text view i have to make bold some titles.can i set it in my interface builder?anyone have idea?is it possible with any other uiobjects like uilabel or something?I tried with an image view but it is not clear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您使用文本视图来显示帮助提示,我认为它是不可编辑的。如果您在这种情况下想要更丰富的格式,那么我认为 UIWebView 提供了更好的解决方案,因为它支持整个 HTML 标记。因此,您可以使用粗体、斜体以及 CSS 提供的几乎所有内容。
Since you are using the text view to show help tips I assume it is non editable. If you want richer formatting in this case then I think UIWebView offers better solution, as it supports entire HTML markup. So you can use bold, italics and pretty much everything that CSS offers.
我认为您正在寻找
UIFont
。您可以设置font
属性或文本,并使用setFont
属性将其分配给您的标签/textview/等。请通读文档
UIFont
!注意:
UITextView
只允许所有文本使用单一统一字体。如果您想要不同的字体大小,我建议您创建单独的UILabel
和UITextView
并将它们作为子视图添加到您的self.view
中,然后对齐他们完美。这应该可以解决问题。但如果您只想使用一个对象来执行此操作,我建议使用UIWebView
或CoreText
或可能是CATextLayer
的NSAttributedString
。I think you are looking for
UIFont
. You can set thefont
property or text, and assign it to your label/textview/etc.. with thesetFont
property.Please read through the Documentation of
UIFont
!Note:
UITextView
allows only a single uniform font for all text. If you want different font size I would suggest that you create separateUILabel
andUITextView
and add them as subviews to yourself.view
, and align them perfectly. This should solve the problem. But if you want to use only one object for this operation, I would suggestUIWebView
, orCoreText
or may beCATextLayer
'sNSAttributedString
.