- (void)viewDidLoad {
[super viewDidLoad];
_imageArray= [[NSMutableArrayalloc]init];
for(inti =1; i <10; i ++) {
NSString*imageName = [NSStringstringWithFormat:@"%d.jpg",i];
UIImage*image = [UIImageimageNamed:imageName];
[_imageArrayaddObject:image];
}
_imageView.image = _imageArray[0];
}
- (IBAction)tapAction:(id)sender {
_index++;
if (_index == _imageArray.count) {
_index=0;
}
_imageView.image = _imageArray[_index];
//添加转场动画
CATransition*transition = [[CATransitionalloc]init];
//设置属性
/*st kCATransitionFade
st kCATransitionMoveIn
st kCATransitionPush
st kCATransitionReveal*/
//设置动画类型
// transition.type = kCATransitionReveal;
/*kCATransitionFromRight
kCATransitionFromLeft
kCATransitionFromTop
kCATransitionFromBottom*/
//设置动画的方向
////私有:rippleEffect 水滴、cube立方体翻转、suckEffect收起效果
transition.type=@"rippleEffect";
transition.subtype= kCATransitionFromRight;
transition.duration=1;
[_imageView.layeraddAnimation:transitionforKey:nil];
}
//自定义push动画
SecondViewController *secondCtrl = [[SecondViewController alloc] init];
CATransition*transition = [[CATransitionalloc]init];
// transition.duration = 1;
transition.type=@"rippleEffect";
transition.subtype = kCATransitionFromTop;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:secondCtrl animated:NO];