Skip to content

Instantly share code, notes, and snippets.

@tewha
Created July 5, 2011 22:34
Show Gist options
  • Save tewha/1066123 to your computer and use it in GitHub Desktop.
Save tewha/1066123 to your computer and use it in GitHub Desktop.
animated error
- (void)showError;
{
dispatch_async( dispatch_get_main_queue(), ^ {
// Setup error view; these values are visible as it slides into place.
_errorView.alpha = finalErrorAlpha;
_errorLabel.text = [_error localizedDescription];
// Slide down the error view, with normal alpha.
[UIView animateWithDuration: slideDownDuration
animations: ^{
CGRect frame = _errorView.frame;
frame.origin.y = topMargin;
_errorView.frame = frame;
}
completion: ^void(BOOL finished) {
// Pulse the alpha stronger.
[UIView animateWithDuration: fadeInDuration
animations: ^{
_errorView.alpha = strongErrorAlpha;
}
completion: ^void(BOOL finished2) {
// Back off on the alpha to the normal level.
[UIView animateWithDuration: lessBrightDuration
animations: ^{
_errorView.alpha = finalErrorAlpha;
}];
}];
}];
});
}
@tewha
Copy link
Author

tewha commented Jul 5, 2011

This is the drawback to blocks: Unless you're willing to use assign your code to variables, you end up with heavily indented code and duplicate parameter names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment