How to replicate the Scale Up Animation when an app starts regularly (push app icon on HomeScreen) on an iPhone

StackOverflow https://stackoverflow.com/questions/3416850

Question

i want to replicate the animation when an app starts on iPhone. There is the first view scaling up from 50 % to 100% i think. later I want to use this as a transition between 2 views. Any ideas how to replicate, or is there a ready to use solution from apple in the sdk? Thank you very much :)

Was it helpful?

Solution

You can do the same thing with CABasicAnimation and CAAnimationGroup, I actually thought that Core Animation over UIKit Animations was smoother and It gives you more control.

CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.removedOnCompletion = YES;

CABasicAnimation *fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeAnimation.fromValue = [NSNumber numberWithFloat:0.0];
fadeAnimation.toValue = [NSNumber numberWithFloat:1.0];

CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scaleAnimation.fromValue = [NSNumber numberWithFloat:0.5];
scaleAnimation.toValue = [NSNumber numberWithFloat:1.00];

animationGroup.animations = [NSArray arrayWithObjects:fadeAnimation, scaleAnimation, nil];

[self.layer addAnimation:animationGroup forKey:@"fadeAnimation"];
self.layer.opacity = 1.0;

"There's always more then one way to skin a cat"

OTHER TIPS

You can apply a scale transform to the UIView and then animate it back to it's normal state.

// Set the the view's scale to half
[viewToScale setTransform:CGAffineTransformMakeScale(0.5,0.5)];

// Set the transform back to normal (identity) in an animation when you're
// ready to animate
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[viewToScale setTransform:CGAffineTransformIdentity];
[UIView commitAnimations];

The trick will be you will need to set the view to the smaller scale in a separate run cycle from the animation or you won't see the view animate. So you can set the smaller scale and then call -performSelector:withObject:afterDelay: to actually perform the animation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top