简体   繁体   English

如何设置UISegmentedControl的背景图像

[英]How do I set the background image of a UISegmentedControl

I have a view with a segmentedcontrol in it and I would like to set the background image of that control. 我有一个带分段控件的视图,我想设置该控件的背景图像。 I know that I can change set the tint color, but I want more control over it than that. 我知道我可以更改设置色调颜色,但我想要更多地控制它。 So if I could set a background image that would be cool. 因此,如果我可以设置一个很酷的背景图像。

I found this tutorial on how to achieve this , however it's outdated, and I'm unable to get it working. 我找到了关于如何实现这个的教程 ,但它已经过时了,我无法让它工作。

Could anyone please help me? 有人可以帮帮我吗? I greatly appreciate any help. 我非常感谢任何帮助。

UPDATE UPDATE

Half the solution has been found, if the only thing one needs to support is iOS5 you can use setBackgroundImage:forState:barMetrics:. 找到了一半的解决方案,如果唯一需要支持的是iOS5,你可以使用setBackgroundImage:forState:barMetrics:。 A great tutorial on the matter can be found here. 关于这个问题的一个很好的教程可以在这里找到。

How about this?: setBackgroundImage:forState:barMetrics: 怎么样?: setBackgroundImage:forState:barMetrics:

Straight from the docs 直接来自文档

Note : Available in iOS 5.0 and later. 注意 :适用于iOS 5.0及更高版本。

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

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