在 iPhone 中自定义文本视图

发布于 2024-12-23 10:48:16 字数 137 浏览 4 评论 0原文

在我的应用程序中,我有一个包含大量内容的文本视图,其中为用户显示了一些帮助提示。在该文本视图中,我必须将一些标题加粗。我可以在界面生成器中设置它吗?有人知道吗?是否可以任何其他 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

欢烬 2024-12-30 10:48:16

由于您使用文本视图来显示帮助提示,我认为它是不可编辑的。如果您在这种情况下想要更丰富的格式,那么我认为 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.

江心雾 2024-12-30 10:48:16

我认为您正在寻找UIFont。您可以设置 font 属性或文本,并使用 setFont 属性将其分配给您的标签/textview/等。

UIFont* boldFont = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]];
UIFont* italicFont = [UIFont italicSystemFontOfSize:[UIFont systemFontSize]];

请通读文档 UIFont


注意:UITextView 只允许所有文本使用单一统一字体。如果您想要不同的字体大小,我建议您创建单独的 UILabelUITextView 并将它们作为子视图添加到您的 self.view 中,然后对齐他们完美。这应该可以解决问题。但如果您只想使用一个对象来执行此操作,我建议使用 UIWebViewCoreText 或可能是 CATextLayerNSAttributedString

I think you are looking for UIFont. You can set the font property or text, and assign it to your label/textview/etc.. with the setFont property.

UIFont* boldFont = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]];
UIFont* italicFont = [UIFont italicSystemFontOfSize:[UIFont systemFontSize]];

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 separate UILabel and UITextView and add them as subviews to your self.view, and align them perfectly. This should solve the problem. But if you want to use only one object for this operation, I would suggest UIWebView, or CoreText or may be CATextLayer's NSAttributedString.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文