Skip to content

Instantly share code, notes, and snippets.

@masuhara
Last active November 7, 2015 19:15
Show Gist options
  • Save masuhara/9b19c945be770e4195eb to your computer and use it in GitHub Desktop.
Save masuhara/9b19c945be770e4195eb to your computer and use it in GitHub Desktop.
Button Pop Animation with Objective-C
#pragma mark - Button Animation
- (void)pushButton {
// 1. Use Facebook POP
POPSpringAnimation *scaleAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY];
scaleAnimation.velocity = [NSValue valueWithCGSize:CGSizeMake(3.f, 3.f)];
scaleAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(1.f, 1.f)];
scaleAnimation.springBounciness = 18.0f;
[button.layer pop_addAnimation:scaleAnimation forKey:@"layerScaleSpringAnimation"];
// 2. Use CABasicAnimation
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"];
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
anim.duration = 0.08;
anim.repeatCount = 2;
anim.autoreverses = YES;
anim.removedOnCompletion = YES;
anim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.15, 1.15, 1.0)];
[button.layer addAnimation:anim forKey:nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment