ios duang 动画简记

+ (void)showAnimationFlashWithView:(UIView *)animationView duration:(CGFloat)duration {
    CAKeyframeAnimation *popAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
    if (!duration) {
        popAnimation.duration = .8;
    }
    popAnimation.duration = duration;
    popAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.0f, 0.01f, 1.0f)],[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1f, 1.1, 1.0f)],[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9f, 0.9, 1.0f)],[NSValue valueWithCATransform3D:CATransform3DIdentity]];
    popAnimation.keyTimes = @[@0.2f,@0.5f,@0.75f,@1.0f];
    popAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut],[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
    [animationView.layer addAnimation:popAnimation forKey:nil];
}
   /*动画速度,何时快、慢
    (
    kCAMediaTimingFunctionLinear 线性(匀速)|
    kCAMediaTimingFunctionEaseIn 先慢|
    kCAMediaTimingFunctionEaseOut 后慢|
    kCAMediaTimingFunctionEaseInEaseOut 先慢 后慢 中间快|
    kCAMediaTimingFunctionDefault 默认|
    )
    */
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
    
    
    /*动画效果
     (
     kCATransitionFade淡出|
     kCATransitionMoveIn覆盖原图|
     kCATransitionPush推出|
     kCATransitionReveal底部显出来
     )
     */        
    [animation setType:kCATransitionPush];
    
    /*动画方向
     (
     kCATransitionFromRight|
     kCATransitionFromLeft|
     kCATransitionFromTop|
     kCATransitionFromBottom
     )
     */
[anim setFromValue:[NSValue valueWithCATransform3D:CATransform3DIdentity]]; //放在3D坐标系中最正的位置


你可能感兴趣的:(ios duang 动画简记)