简体   繁体   中英

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.

Is it possible for the second one to not get highlighted unless the first is pressed prior?

Set both buttons' exclusiveTouch property as true.

When exclusiveTouch property is set to true, you won't be able to touch both of them at the same time.

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

override func viewDidLoad() {
    super.viewDidLoad()

    button1.exclusiveTouch = true
    button2.exclusiveTouch = true
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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