转场动画

  • (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
//添加转场动画
CATransition *anim = [CATransition animation];

anim.duration = 1;

//设置转场类型
//@"cube" @"moveIn" @"reveal" @"fade"(default) @"pageCurl" @"pageUnCurl" @"suckEffect" @"rippleEffect" @"oglFlip"
anim.type = @"oglFlip";
anim.subtype = @"fromRight";
[self.imageV.layer addAnimation:anim forKey:@"kCTransitionAnimation"];


//转场代码 跟转场动画必须得要在同一个方法当中
_i++;

if (_i > 3) {
    _i = 1;
}

NSString *imageName = [NSString stringWithFormat:@"%d",_i];
self.imageV.image = [UIImage imageNamed:imageName];

// UIView *view = [[UIView alloc]init];
// [view.layer addAnimation:anim forKey:nil];
// self.imageV.backgroundColor = [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1];

}

你可能感兴趣的:(转场动画)