CALayer--跳转动画

- (void)CATransition{

    //转场代码必须得要和转场动画在同一个方法当中.
    //创建动画
    CATransition *anim = [CATransition animation];
    anim.type = @"push";
    anim.duration = 1;


    [self.imageV.layer addAnimation:anim forKey:nil];
    
    [self performSelector:@selector(nextAnimition) withObject:self afterDelay:2];
    //转场代码
    
    _i++;
    if (_i > 3) {
        _i = 1;
    }
    NSString *imageName = [NSString stringWithFormat:@"%d",_i];
    self.imageV.image = [UIImage imageNamed:imageName];
    
    
   
}

- (void)nextAnimition
{
       CATransition *anim = [CATransition animation];
        //设置转场类型
        anim.type = @"rippleEffect";
    
        //设置转场的方向
        anim.subtype = kCATransitionFromBottom;
        //设置动画的开始点.
        anim.startProgress = 0.2;
        //设置动画的结束点.
        anim.endProgress = 0.8;
    
        anim.duration = 1;
        [self.imageV.layer addAnimation:anim forKey:nil];
 
}

  • anim.type


    屏幕快照 2017-01-20 下午3.30.06.png

你可能感兴趣的:(CALayer--跳转动画)