简体   繁体   English

UISegmentedControl自定义背景图片

[英]UISegmentedControl custom background image

I have UINavigationBar setup as image - some wood texture. 我将UINavigationBar设置为图像 - 一些木质纹理。 I want to insert UISegmentedControl with 4 buttons on that bar. 我想在该栏上插入带有4个按钮的UISegmentedControl。 Buttons should have same texture with slightly changed tint. 按钮应具有相同的纹理,略微改变色调。

One solution would be to change tint alpha of buttons background color, so that texture in background can get trough, but as I set alpha for tint in IB it doesn't save value, it always gets back to value 1. 一种解决方案是改变按钮背景颜色的色调α,以便背景中的纹理可以得到低谷,但是当我在IB中为色调设置alpha时它不会保存值,它总是返回值1。

I cant get UISegmentedControl to show background image, so finally gave up and decide to search for help... Effect that is desired is one in iBooks app, with buttons in Navigation Bar. 我不能让UISegmentedControl显示背景图像,所以最后放弃并决定寻求帮助...期望的效果是iBooks应用程序中的一个,导航栏中有按钮。 Any link or small help would be appreciated.. 任何链接或小帮助将不胜感激..

这篇文章描述了所涉及的步骤,并提供了示例代码: http//idevrecipes.com/2010/12/13/wooduinavigation/

https://github.com/xhan/PlutoLand/blob/master/PlutoLand/UI/PLSegmentView.h https://github.com/xhan/PlutoLand/blob/master/PlutoLand/UI/PLSegmentView.h

a custom SegmentView that can specify two images(normal, clicked) 自定义SegmentView,可以指定两个图像(正常,单击)

Do not bother with one of those custom segmented control packages if you're on iOS 5 or later. 如果您使用的是iOS 5或更高版本,请不要使用其中一个自定义分段控件包。

Per Dylan 's suggestion, use the Appearance functionality in iOS 5+. 按照Dylan的建议,使用iOS 5+中的Appearance功能。

See the top answer here: Customizing Left & Right UISegmentedControl Buttons 请参阅此处的最佳答案: 自定义左右UISegmentedControl按钮

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

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