视图动画效果 通过layer层实现

    // 准备动画
    CATransition *animation = [CATransition animation];
    
    //动画播放持续时间
    [animation setDuration:3.0f];
    
    /*动画速度,何时快、慢
    (
    kCAMediaTimingFunctionLinear 线性(匀速)|
    kCAMediaTimingFunctionEaseIn 先慢|
    kCAMediaTimingFunctionEaseOut 后慢|
    kCAMediaTimingFunctionEaseInEaseOut 先慢 后慢 中间快|
    kCAMediaTimingFunctionDefault 默认|
    )
    */
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
    
    
    /*动画效果
     (
     kCATransitionFade淡出|
     kCATransitionMoveIn覆盖原图|
     kCATransitionPush推出|
     kCATransitionReveal底部显出来
     )
     */        
    [animation setType:kCATransitionPush];
    
    /*动画方向
     (
     kCATransitionFromRight|
     kCATransitionFromLeft|
     kCATransitionFromTop|
     kCATransitionFromBottom
     )
     */
    if (nextControllerIndex < currentControllerIndex)
        [animation setSubtype:kCATransitionFromRight];
    else
        [animation setSubtype:kCATransitionFromLeft];

    [viewController.view.layer addAnimation:animation forKey:@"Reveal"];   

你可能感兴趣的:(animation,layer)