Created
May 28, 2015 22:20
-
-
Save BradB132/10f51b313530bac275ec to your computer and use it in GitHub Desktop.
AutoLayoutRecipesPt1-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBOutlet weak var constraint1: NSLayoutConstraint! | |
@IBOutlet weak var constraint2: NSLayoutConstraint! | |
@IBAction func animateViews(sender: AnyObject) { | |
constraint1.constant = CGFloat(arc4random_uniform(200)) | |
constraint2.constant = CGFloat(arc4random_uniform(200)) | |
UIView.animateWithDuration(0.5, animations: { | |
self.view.setNeedsUpdateConstraints() | |
self.view.layoutIfNeeded() | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@BradB132 I'm reading through your autolayout blog posts (they are extremely helpful, thank you!) and I don't understand why in some of your action outlets you are able to change the
constraint.constant
value and the UI will update accordingly but in this example you callsetNeedsUpdateConstraints
andlayoutIfNeeded
Why doesn't the UI update immediately after executing line 5 and again after executing line 6 ?