什么UI元素在Cocoa Touch是这个? [英] What UI element in Cocoa Touch is this?
问题描述
我在我的iPod Touch上的邮件应用程序中看到这个,我想知道这是否是一个UI元素。如果没有,我该如何重现呢?
I see this in the mail application on my iPod Touch and I'm wondering if this is a UI element. If not, how can I reproduce it?
推荐答案
在桌面上,这将被称为令牌字段。它们首先出现在Mail.app中,并最终成为AppKit框架的一部分。 此处的文档。
On the desktop, that'd be called a "token field." They first appeared in Mail.app, and eventually became part of the AppKit framework. Documentation here.
在Cocoa Touch中很容易再现。在Cocoa Touch中,每个视图都有一个核心动画层,并且图层有一个 cornerRadius
属性。将该属性设置为字段高度的一半,以创建圆角端。你可以设置一个背景颜色,如果你没有一个平面的外观,或者你可以画一个微妙的渐变,给一个更凸的外观。
It should be pretty easy to reproduce that look in Cocoa Touch. In Cocoa Touch, every view is backed by a Core Animation layer, and layers have a cornerRadius
attribute. Set that attribute to half the height of the field to create rounded ends. You can set a background color if you're okay with a flat appearance, or you can draw a subtle gradient to give a more convex appearance.
当然,你只有需要做所有的,如果你想要一个可重用的视图,你可以设置文本等。
Of course, you only need to do all that if you want a reusable view where you can set the text and so forth. If you only need a few of these for custom buttons or something, it might be easier to just draw them in your favorite drawing program.
另一种可能性是使用第三种方法来创建自定义按钮。如果你只需要一些自定义按钮或某些东西,方控制,例如:
Another possibility is to use a third party control, such as any of:
COTokenField(属于 COPeoplePickerViewController )
COTokenField (part of COPeoplePickerViewController)
这篇关于什么UI元素在Cocoa Touch是这个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!