dimanche 19 septembre 2021

xcode: unlock button with selecting two or more buttons

I am trying to unlock the third button with the first and second button selected. Need help please. The button is already greyed out and locked but need help with multiple conditions.

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var thirdButton: UIButton!

var bravo = false
var charlie = false




override func viewDidLoad() {
    super.viewDidLoad()
    
    thirdButton.isEnabled = false;
    thirdButton.alpha = 0.5
    
    if bravo == true && charlie == true {
        thirdButton.isEnabled = true;
        thirdButton.alpha = 1.0
    
    } else {
        thirdButton.isEnabled = false;
        thirdButton.alpha = 0.5
        
    }
    
}




    



@IBAction func buttonONe(_ sender: Any) {
    
    bravo = true

}


@IBAction func buttonTwo(_ sender: Any) {
    
    charlie = true
    
}



@IBAction func buttonThree(_ sender: Any) {


}

}

Aucun commentaire:

Enregistrer un commentaire