简体   繁体   English

iPhone iOS5 如何向用户显示字体类型、大小、颜色和 alignment 小部件?

[英]iPhone iOS5 How can I present a font type, size, color and alignment widget to the user?

I have a few UITextFields and I would like the user to be able to change the font's appearance within those fields.我有几个 UITextFields,我希望用户能够在这些字段中更改字体的外观。

Right now I have a UIToolbar with 5 buttons used for font controls.现在我有一个带有 5 个用于字体控制的按钮的 UIToolbar。 One for font name, one for size, one for color and one for alignment.一种用于字体名称,一种用于大小,一种用于颜色,一种用于 alignment。

To change font, I display a picker with the fonts family names, letting the user pick default font for that family.为了更改字体,我显示了一个带有 fonts 系列名称的选择器,让用户为该系列选择默认字体。

For the font color, I display another toolbar with a font size slider For font color, I display an open source color picker For font alignment, I display a button that cycles through the left/center/right alignment. Finally there's a close button that hides the toolbar.对于字体颜色,我显示另一个工具栏,字体大小为 slider 对于字体颜色,我显示一个开源颜色选择器 对于字体 alignment,我显示一个循环通过左/中/右 alignment 的按钮。最后有一个关闭按钮隐藏工具栏。

Currently all of my code is in one controller, but I would like to have it refactored into a separate, reusable class.目前我所有的代码都在一个 controller 中,但我想将它重构为一个单独的、可重复使用的 class。

Since I'll be rewriting code, are there any open source font controls like I'm describing above?由于我将重写代码,是否有像我上面描述的那样的开源字体控件? Maybe I can just plug in something that's already made into my project?也许我可以插入一些已经制作到我的项目中的东西?

Thank you!谢谢!

It wouldn't be very hard at all.一点也不难。 Instead of pickers use a scroll view with buttons and labels above them using the font.使用字体,而不是选择器使用带有按钮和标签的滚动视图。 As for size you could do the same!至于尺寸,你也可以这样做!

This would be easy in Xcode 4, not so sure in 3.XX这在 Xcode 4 中很容易,在 3.XX 中不太确定

I found that the attributed string example by apple does have a table view-like font controller that includes a preview of what fonts look like.我发现苹果的属性字符串示例确实有一个类似表视图的字体 controller,其中包括 fonts 的预览。 I think extending that controller may be the easiest thing to do:我认为扩展 controller 可能是最简单的事情:

http://developer.apple.com/library/ios/#samplecode/CoreTextPageViewer/Introduction/Intro.html http://developer.apple.com/library/ios/#samplecode/CoreTextPageViewer/Introduction/Intro.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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