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

后端 未结 2 461
走了就别回头了
走了就别回头了 2020-12-29 00:23

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 betwee

相关标签:
2条回答
  • 2020-12-29 01:00

    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"

    0 讨论(0)
  • 2020-12-29 01:13

    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.

    0 讨论(0)
提交回复
热议问题