Skip to content

Instantly share code, notes, and snippets.

@betzerra
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save betzerra/68957450ed5d6e9dd912 to your computer and use it in GitHub Desktop.
Save betzerra/68957450ed5d6e9dd912 to your computer and use it in GitHub Desktop.
Spring animation using iOS 7
// Set startFrame and endFrame for _contentView
CGRect endFrame = _contentView.frame;
CGRect startFrame = endFrame;
startFrame.origin.y = -startFrame.size.height;
_contentView.frame = startFrame;
void (^animationBlock)(void) = ^(void){
_contentView.frame = endFrame;
};
/* usingSprintWithDamping: value between 0 and 1.
* Employ a damping ratio closer to zero to
* increase oscillation.
*
* initialSpringVelocity: a value of 1 corresponds
* to the total animation distance traversed in one
* second. The higher its value, the faster its initial
* speed. */
[UIView animateWithDuration:1.0
delay:0.15
usingSpringWithDamping:0.6
initialSpringVelocity:7
options:0
animations:animationBlock
completion:nil];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment