[TOC]

1.CATransition

CATransition:转场动画;提供渐变效果,如推拉push效果,消退fade效果,揭开reveal效果;

API

@interface CATransition : CAAnimation

@property(copy) NSString *type; //方式
@property(nullable, copy) NSString *subtype; //方向

@property float startProgress;
@property float endProgress;

@property(nullable, strong) id filter; //An optional Core Image filter object that provides the transition.

@end

//Common Transition Types
CA_EXTERN NSString * const kCATransitionFade;
CA_EXTERN NSString * const kCATransitionMoveIn;
CA_EXTERN NSString * const kCATransitionPush;
CA_EXTERN NSString * const kCATransitionReveal;

//Common transition subtypes.
CA_EXTERN NSString * const kCATransitionFromRight;
CA_EXTERN NSString * const kCATransitionFromLeft;
CA_EXTERN NSString * const kCATransitionFromTop;
CA_EXTERN NSString * const kCATransitionFromBottom;

应用

代码参见:“demo_XYAnim”。

///隐藏TabBar的动画:
- (void)hide {
    //创建转场动画对象
    CATransition *animation = [CATransition animation];

    //动画持续时间
    animation.duration = 3.0f;
    //方式
    animation.timingFunction=UIViewAnimationCurveEaseInOut;
    //转场动画类型
    animation.type = kCATransitionReveal;
    //转场动画将去的方向
    animation.subtype = kCATransitionFromBottom;
    //动画时你需要的实现
    self.tabBarController.tabBar.hidden = YES;
    //添加动画 (转场动画是添加在层上的动画)
    [self.tabBarController.tabBar.layer addAnimation:animation forKey:@"animation"];
}

///显示TabBar的动画:
- (void)show {
    //动画对象
    CATransition *animation = [CATransition animation];

    //动画持续时间
    animation.duration = 3.0f;
    //方式
    animation.timingFunction=UIViewAnimationOptionCurveEaseInOut;
    //转场动画类型
    animation.type = kCATransitionMoveIn;
    //转场动画将去的方向
    animation.subtype = kCATransitionFromTop;
    //动画时你需要的实现
    self.tabBarController.tabBar.hidden = NO;
    //添加动画 (转场动画是添加在层上的动画)
    [self.tabBarController.tabBar.layer addAnimation:animation forKey:@"animation"];
}

results matching ""

    No results matching ""