有没有办法为 iphone sdk 上的 xib 文件上的文本视图提供格式?

发布于 2024-10-08 09:02:53 字数 325 浏览 0 评论 0原文

我一直在尝试格式化文本视图,因为我想制作一个漂亮但看起来简单的文本视图,但我无法做到这一点。一直在四处寻找但未能做到这一点。因此,现在我请求您的专业知识并就此事寻求帮助。
我想做的就是以人们能够正确阅读的方式格式化文本,例如:

Recipie

Ingredients
1 杯上升
1 1/2 肉桂茶丝
1 张卡罗纺制桌子。

程序
首先添加......

最后将所有东西放入一个大碗中并享用。

就这么简单,但它不让我这样做。所以请如果有任何天才寻求帮助
我会非常感激的。

I am stuck trying to formatting a textview, because I want to make a nice but simple looking textview but I cant manage to do it. been looking all around but havent been able to do so. So now I plead to your expertise and ask for help in the matter.
All I want to do is format the text in a way that people be able to read it properly, example:

Recipie

Ingredients:
1 Cup of rise
1 1/2 tea spuns of cinnamon
1 table spun of karo.

Procedure:
start by adding the ....

end placing every thing in a big bowl and enjoy.

as simple as that but it wont let me do it. so please if there is any genius looking to help
I will appreciate it a lot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

半岛未凉 2024-10-15 09:02:54

我发现对于涉及多种字体或自定义对齐方式的任何内容,最好的办法是用 HTML 编写并使用 UIWebView。

I've found that for anything involving multiple fonts or custom alignments, the best thing is to write it in HTML and use a UIWebView.

病女 2024-10-15 09:02:54

您可以做的是使用 JTextView 代码。它并不完整(编辑支持尚未准备好),但可用于文本显示(阅读:非编辑)

它使用 CoreText 进行绘制,并采用 NSAttributedString 作为文本存储。您为特定的文本运行定义属性(不同的字体、大小等),此文本视图将为您绘制该属性。

更具体地说,您可以在 NSAttributedString 中执行此操作,然后将其设置为 attributedText

代码在这里

What you can do is use JTextView code. It's not complete (editing support is what's not ready for prime time), but usable for text display (read: non-editing)

It uses CoreText to draw, and takes an NSAttributedString as a text store. You define your attributes (different font, size, etc) for a specific run of text, and this text view will draw that for you.

More specifically, you do this in your NSAttributedString, which you then set as the attributedText.

Code is here.

不语却知心 2024-10-15 09:02:54

感谢大家,但由于我听到的崩溃问题,我试图避免使用 UIWEBVIEW,并且我找到了一种最简单的方法使其按照我需要的方式工作,我决定使用标签(如粗体文本)和显示普通文本的文本视图;为他们提供您想要的字体和大小,并且效果很好。如果需要,您甚至可以在滚动视图中使用它们。哈哈。

THANKS TO EVERY ONE, BUT I WAS TRYING TO AVOID THE UIWEBVIEW BECAUSE OF THE CRASHES PROBLEMS I HEARD, AND I FOUND AN EASIEST WAY TO MAKE IT TO WORK THE WAY THAT I NEEDED, I DECIDE TO USE LABELS (AS THE BOLD TEXT) AND TEXTVIEWS TO DISPLAY THE NORMAL TEXT; GIVING THEM THE FONT AND SIZE YOU WANT, AND ITS WORKING FINE. YOU CAN EVEN USE THEM IN A SCROLLVIEW IF NEEDED. LOL.

野心澎湃 2024-10-15 09:02:53

我建议将 UIWebView 与 HTML 文档一起使用。这将为您提供终极的格式化功能。

I would suggest using a UIWebView with an HTML document. That will give you the ultimate format capabilities.

请止步禁区 2024-10-15 09:02:53

老实说,我会将其放入 UIWebView 中,这样您就可以按照您想要的方式使用 html 和 css 格式。您将不得不执行太多的解决方法来更改其不同部分的文本大小,并且必须进行子类化和其他废话。

您有什么理由需要使用文本视图吗?

I would honestly put this into a UIWebView, that way you can use html and css formatting the way you want. You would have to do too many workarounds to to change the text sizes of the different parts of it and have to subclass and other nonsense.

Is there any reason that you need to use a textview?

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