邮件应用程序中的 UISegmentedControl
如何获得一个类似于邮件应用程序中的 UISegmentedControl,以便它与 UIToolbar 按钮颜色相同(就好像两个段都处于选定状态一样)。
我想使用分段控件来达到与邮件完全相同的目的。
(在 iPad 上,所以是灰色而不是蓝色)
How do I get a UISegmentedControl that is like the one in the Mail App, so that it is the same colour as UIToolbar buttons (as if both segments were in the selected state).
I want to use the segmented control for exactly the same purpose as Mail.
(on the iPad, so a grey not blue color)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这是来自 Apple 示例代码的代码...导航栏以及代码中使用的两个图像..
您应该能够获得与邮件应用程序完全相同的视图。
This is code from Apple Sample codes... NavBar and both the images used in the code..
you shoud be able to get exact same view as mail App.
您正在寻找
tintColor
属性!当您使用
UISegmentedControl
时,您可以将其色调更改为您可以想象的任何颜色。因此,如果您在 Interface Builder 中添加了 UISegmentedControl,那么您可以在- (void)viewWillAppear:(BOOL)animated
方法中设置它的样式(假设您已将其连接到 @synthesized ivar:现在显然你会想要使用我在上面的示例代码中放入的红色、绿色、蓝色和 alpha 颜色,但是你可以从字面上为 UISegmentedController 着色任何你想要的颜色(或者使其像你想要的那样透明) ),因此只需找到适合您的 RGBA 值即可。
请记住,根据 Apple 文档,此属性的默认值为 nil(无颜色),仅当 UISegmentedControl 的样式时才使用此属性。分段控件是UISegmentedControlStyleBar。
祝你好运!
You seek the
tintColor
property!When you use a
UISegmentedControl
you can change its tint color to any color you can dream up. So, if you added the UISegmentedControl in Interface Builder then you would style it in your- (void)viewWillAppear:(BOOL)animated
method as such (assuming you had it hooked up to a @synthesized ivar:Now obviously you will want to play with the red, green, blue, and alpha's that I've put in the sample code above, but you can literally tint the UISegmentedController any color you would like (or make it as transparent as you would like), so it's just a matter of finding the RGBA values that look perfect to you.
Remember that per Apple's docs that
the default value of this property is nil (no color). UISegmentedControl uses this property only if the style of the segmented control is UISegmentedControlStyleBar.
Good luck!
我不知道你的意思..但我相信“UISegmentedControlStyleBar”可能是segmentedControlStyle。
您也可以在 IB 中设置此属性! (这是称为“样式”的属性)
I dont know exactly what you mean.. but i believe the "UISegmentedControlStyleBar" as segmentedControlStyle could it be.
You can set this property in the IB too! (It's the property called "style")
我正在寻找的样式没有记录:它是样式 4。
看起来他在这里向上/向下控制: http://media.mobilemeandering.com/wp-content/uploads/2010/04/ipad-mail-message-2.png
(顺便说一句,不是我的图像)
它基本上使所有部分看起来都被选中,它用于瞬时推动,并且实际上是将多个工具栏按钮推到一起。
因此它不能在 IB 中设置,而必须在代码中设置或通过将 nib 作为文本文件打开来在 nib/xib 文件中手动设置。
The style I'm looking for is undocumented: it is style 4.
It looks like he up/down control here: http://media.mobilemeandering.com/wp-content/uploads/2010/04/ipad-mail-message-2.png
(not my image btw)
It basically makes all segments look selected, it's intended for momentary pushes, and is effectively multiple tool bar buttons pushed up together.
So it can't be set in IB but must be set in code or manually in the nib/xib file, by opening the nib as a text file.
我不确定我是否完全理解你想要做什么,但我会尝试一下。
解决方案并不明显,您需要使用 UISearchDisplayController 以获得匹配的 UISearchBar 和 UISegmentedControl。
有关示例,请参阅 TableSearch 示例代码。
I'm not sure I exactly understand what you're trying to do, but I'll give it a shot.
The solution is not obvious, you need to use a UISearchDisplayController in order to get a matching UISearchBar and UISegmentedControl.
See the TableSearch sample code for an example.