Created
March 21, 2012 21:04
-
-
Save bjhomer/2152823 to your computer and use it in GitHub Desktop.
A useful pattern for UIKit's -setFoo:animated: methods
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
- (void)setFoo:(BOOL)foo animated:(BOOL)animated { | |
[super setFoo:foo animated:animated]; | |
dispatch_block_t changes = ^{ | |
if (foo) { | |
someView.alpha = 1.0; | |
} | |
else { | |
someView.alpha = 0.0; | |
} | |
}; | |
if (animated) { | |
[UIView animateWithDuration:0.2 animations:changes]; | |
} | |
else { | |
changes(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment