Created
January 8, 2019 02:53
-
-
Save 0xABCCBA/9b3030ccd815b746e19a17bb5d32fe44 to your computer and use it in GitHub Desktop.
use layoutIfNeeded
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
// use a button click to show how layoutIfNeeded() works | |
// article link: https://medium.com/@abhimuralidharan/ios-swift-setneedslayout-vs-layoutifneeded-vs-layoutsubviews-5a2b486da31c | |
@IBAction func heightPressed(_ sender: AnyObject) { | |
view.layoutIfNeeded() | |
if(self.blueHeight.constant == 25.0) | |
{ | |
self.blueHeight.constant = self.view.bounds.height - 100.0 | |
} | |
else | |
{ | |
self.blueHeight.constant = 25.0 | |
} | |
UIView.animate(withDuration: 2.0, animations: { | |
self.view.layoutIfNeeded() | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment