//CA_EXTERN NSString * const kCATransitionFade //__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0); //CA_EXTERN NSString * const kCATransitionMoveIn //__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0); //CA_EXTERN NSString * const kCATransitionPush //__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0); //CA_EXTERN NSString * const kCATransitionReveal //__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0); /* Common transition subtypes. */ //CA_EXTERN NSString * const kCATransitionFromRight //__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0); //CA_EXTERN NSString * const kCATransitionFromLeft //__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0); //CA_EXTERN NSString * const kCATransitionFromTop //__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0); //CA_EXTERN NSString * const kCATransitionFromBottom //__OSX_AVAILABLE_STARTING (__MAC_10_5, __IPHONE_2_0); /** * 上一张 */ - (IBAction)previous { //索引加1 ,1 self.count--; //创建转场对象 CATransition *animation = [CATransition animation]; /* 过渡效果 */ //fade //交叉淡化过渡(不支持过渡方向) kCATransitionFade //push //新视图把旧视图推出去 kCATransitionPush //moveIn //新视图移到旧视图上面 kCATransitionMoveIn //reveal //将旧视图移开,显示下面的新视图 kCATransitionReveal ///******下面几个也是过渡效果,但它们是私有API效果,使用的时候要小心,可能会导致app审核不被通过***/ //cube //立方体翻滚效果 //oglFlip //上下左右翻转效果 //suckEffect //收缩效果,如一块布被抽走(不支持过渡方向) //rippleEffect //滴水效果(不支持过渡方向) //pageCurl //向上翻页效果 //pageUnCurl //向下翻页效果 //cameraIrisHollowOpen //相机镜头打开效果(不支持过渡方向) //cameraIrisHollowClose //相机镜头关上效果(不支持过渡方向) //设定转场的动画模式 animation.type = @"push"; //设定转场fangXiang animation.subtype = @"fromTop"; //ABS()可以取绝对值 NSString *imageName = [NSString stringWithFormat:@"%zd",ABS(self.count % 7) + 1]; self.iconView.image = [UIImage imageNamed:imageName]; [self.iconView.layer addAnimation:animation forKey:nil]; } /** * 下一张 */ - (IBAction)next { //索引加1 ,1 self.count++; //创建转场对象 CATransition *animation = [CATransition animation]; //设定转场的动画模式 animation.type = kCATransitionFade; //设定转场fangXiang animation.subtype = kCATransitionFromRight; //ABS()可以取绝对值 NSString *imageName = [NSString stringWithFormat:@"%zd",ABS(self.count % 7) + 1]; self.iconView.image = [UIImage imageNamed:imageName]; [self.iconView.layer addAnimation:animation forKey:nil]; }