vendredi 2 septembre 2016

How to make a function run a if else statement?

The code below deactivates one constraints for a new one. But it only goes one way; how can the code be written in a if else statement so that it goes from old constraint to new constraint and new constraint to old constraint. This is how I would pseudo code it. IF A IS RUNNING END A AND RUN B; IF B IS RUNNING END B AND RUN A. This is would be in a loop.

 func myFunction(sender: AnyObject) {


        NSLayoutConstraint.deactivateConstraints(initialc)

        let widthc = colorview.widthAnchor.constraintEqualToConstant(100)
        let heightc = colorview.heightAnchor.constraintEqualToConstant(100)
        let centerxc = colorview.centerXAnchor.constraintEqualToAnchor(self.view.centerXAnchor)
        let centeryc = colorview.centerYAnchor.constraintEqualToAnchor(self.view.centerYAnchor)

        NSLayoutConstraint.activateConstraints([widthc,heightc,centerxc,centeryc])

    }

Aucun commentaire:

Enregistrer un commentaire