Last active
May 11, 2016 21:06
-
-
Save tempire/0cee2559bc5c0830fe289f9460e171b3 to your computer and use it in GitHub Desktop.
objc block closure
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)setHighlighted:(BOOL)highlighted animated:(BOOL)animated duration:(NSTimeInterval)duration completion:(void(^)(BOOL finished))completion { | |
void (^highlight)(UIView *, BOOL) = ^void(UIView *view, BOOL highlight) { | |
if (highlight) { | |
view.layer.borderWidth = 0.0; | |
view.layer.borderColor = [UIColor clearColor].CGColor; | |
view.layer.shadowOpacity = 0.0; | |
} | |
else { | |
view.layer.borderWidth = 1.0; | |
view.layer.borderColor = [UIColor blackColor].CGColor; | |
view.layer.shadowOpacity = 2.0; | |
view.layer.shadowColor = [UIColor yellowColor].CGColor; | |
view.layer.shadowOffset = CGSizeMake(0, 0); | |
view.layer.shadowRadius = 5.0; | |
} | |
}; | |
if (animated) { | |
[UIView animateWithDuration:duration animations:^{ | |
highlight(self, highlighted); | |
} completion:completion]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment