Created
July 5, 2011 22:34
-
-
Save tewha/1066123 to your computer and use it in GitHub Desktop.
animated error
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)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; | |
}]; | |
}]; | |
}]; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.