使用 UIButtons 复制 UISegmentedControl - iPhone
我不喜欢 UISegmentedControl 的风格,因此我尝试改变它的外观,但我无法将图像附加到其按钮上。我只是一点都没改变。
现在我正在研究如何使用 4 个 UIButtons 复制该功能。
我在界面生成器中设置了 4 个 UIButton,并为它们添加了不同的标签号。
我无法完成的是,当点击一个按钮时,它应该被“选择”,而其他按钮应该被取消选择。
我怎样才能连接所有这些?
如果有办法改变 UISegmented 控件的外观,我将需要所有这些努力。
感谢大家的帮助,
这是针对 iPhone 操作系统的
I didnt like the style of UISegmentedControl, hence i tried to change the way it looked, but I couldnt attach images to its buttons. I just didnt change at all.
Now i'm looking at how to replicate that function with 4 UIButtons.
I've setup 4 UIButtons in interface builder, added different tag numbers to them.
What i cannot accomplish is when a button is tapped, it should be "selected" and the other buttons should be Unselected.
How can i connect all of them?
And if there was a way to change the UISegmented control looks, i would need all this effort.
thanks for the help guys
this is for iPhone OS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 4 个按钮,关闭所有其他按钮并不太困难。这里有一些代码可以帮助您入门:
这里需要注意的重要设置:
depressed
状态。这样,如果选择了某个项目,您只需更换按钮的图像或背景即可使其看起来压抑。buttons
是一个数组,其中填充了此子类 uibutton 对象。您可以在 viewDidLoad 中设置它;Using 4 buttons, it is not too difficult to turn off all the others. Here is some code to get you started:
Important setup to note here:
depressed
state. This way, if an item is selected, you simply swap out the image or background of the button to make it looked depressed.buttons
is an array that is filled with this subclassed uibutton object. You would set it up in viewDidLoad;