Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ArtSabintsev/7307022 to your computer and use it in GitHub Desktop.
Save ArtSabintsev/7307022 to your computer and use it in GitHub Desktop.
I was searching for a way to perform an iOS-6 (and older) style UIAlertView animation pop up. I came across this code from http://stackoverflow.com/a/3004247/814861. I've copied it over here for my own records (with very slight readability modifications).
- (void)popView:(UIView *)viewToPop
{
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
NSValue *scale1Value = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5f, 0.5f, 1.0f)];
NSValue *scale2Value = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2f, 1.2f, 1.0f)];
NSValue *scale3Value = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9f, 0.9f, 1.0f)];
NSValue *scale4Value = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)];
NSArray *frameValues = [NSArray arrayWithObjects:scale1Value, scale2Value, scale3Value, scale4Value, nil];
[animation setValues:frameValues];
NSNumber *time1 = [NSNumber numberWithFloat:0.0f];
NSNumber *time2 = [NSNumber numberWithFloat:0.5f];
NSNumber *time3 = [NSNumber numberWithFloat:0.9f];
NSNumber *time4 = [NSNumber numberWithFloat:1.0f];
NSArray *frameTimes = [NSArray arrayWithObjects:time1, time2, time3, time4, nil];
[animation setKeyTimes:frameTimes];
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
animation.duration = 0.2f;
[viewToPop.layer addAnimation:animation forKey:@"popup"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment