简体   繁体   English

如何防止按钮突出显示

[英]How to prevent button highlight

I have a project with 2 buttons on my storyboard, I can click both at the same time, but only one triggers. 我的故事板上有一个带有2个按钮的项目,我可以同时单击两个按钮,但是只有一个触发器。

Is it possible for the second one to not get highlighted unless the first is pressed prior? 除非事先按下第一个按键,否则第二个按键可能不会突出显示吗?

Set both buttons' exclusiveTouch property as true. 将两个按钮的ExclusiveTouch属性都设置为true。

When exclusiveTouch property is set to true, you won't be able to touch both of them at the same time. 当ExclusiveTouch属性设置为true时,您将无法同时触摸它们两者。

@IBOutlet weak var button1: UIButton!
@IBOutlet weak var button2: UIButton!

override func viewDidLoad() {
    super.viewDidLoad()

    button1.exclusiveTouch = true
    button2.exclusiveTouch = true
}

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

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