iphone - 如何设置 UISegmentedControl 的背景图片

标签 iphone ios uisegmentedcontrol

我有一个带有分段控件的 View ,我想设置该控件的背景图像。我知道我可以更改设置的色调,但我想要更多地控制它。因此,如果我可以设置一个很酷的背景图片。

我找到了 this tutorial on how to achieve this ,但是它已经过时了,我无法让它工作。

谁能帮帮我?我非常感谢任何帮助。

更新

已经找到了一半的解决方案,如果唯一需要支持的是 iOS5,您可以使用 setBackgroundImage:forState:barMetrics:。 A great tutorial on the matter can be found here.

最佳答案

这个怎么样?:setBackgroundImage:forState:barMetrics:

直接来自文档

注意:适用于 iOS 5.0 及更高版本。

关于iphone - 如何设置 UISegmentedControl 的背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7894946/

相关文章:

iphone - 获取id中的内容

iOS蓝牙设备在输入错误密码后无法取消配对或忘记

ios - 在我的任何代码运行之前,iOS Keyboard Extension崩溃

ios - UINavigationController清除背景色

iphone - 点击分段控制时更改表格 View 。与 APPSTORE 应用程序完全相同。怎么做?

iphone - 如何在 iphone 中通过电子邮件发送 .caf 文件?

ios - restoreCompletedTransactions 并要求登录

带有 YouTube v3 API 和 youtube-ios-player-helper 的 iOS 应用无法自动播放视频

ios - 在分段控件中向 TableView 添加数据的问题

ios - 我需要制作一个同时显示文本和图像的 UISegmentedControl