翻页动画效果
2016-04-14 14:42
369 查看
typedef enum : NSUInteger { Fade = 1, //淡入淡出 Push, //推挤 Reveal, //揭开 MoveIn, //覆盖 Cube, //立方体 SuckEffect, //吮吸 OglFlip, //翻转 RippleEffect, //波纹 PageCurl, //翻页 PageUnCurl, //反翻页 CameraIrisHollowOpen, //开镜头 CameraIrisHollowClose, //关镜头 CurlDown, //下翻页 CurlUp, //上翻页 FlipFromLeft, //左翻转 FlipFromRight, //右翻转 } AnimationType;
- (IBAction)tapButton:(id)sender { UIButton * button = sender; AnimationType animationType = button.tag; NSString * subtypeString; switch (_subtype) { case 0: subtypeString = kCATransitionFromLeft; break; case 1: subtypeString = kCATransitionFromBottom; break; case 2: subtypeString = kCATransitionFromRight; break; case 3: subtypeString = kCATransitionFromTop; break; default: break; } _subtype += 1; if (_subtype > 3) { _subtype = 0; } switch (animationType) { case Fade: [self transitionWithType:kCATransitionFade WithSubtype:subtypeString ForView:self.view]; break; case Push: [self transitionWithType:kCATransitionPush WithSubtype:subtypeString ForView:self.view]; break; case Reveal: [self transitionWithType:kCATransitionReveal WithSubtype:subtypeString ForView:self.view]; break; case MoveIn: [self transitionWithType:kCATransitionMoveIn WithSubtype:subtypeString ForView:self.view]; break; case Cube: [self transitionWithType:@"cube" WithSubtype:subtypeString ForView:self.view]; break; case SuckEffect: [self transitionWithType:@"suckEffect" WithSubtype:subtypeString ForView:self.view]; break; case OglFlip: [self transitionWithType:@"oglFlip" WithSubtype:subtypeString ForView:self.view]; break; case RippleEffect: [self transitionWithType:@"rippleEffect" WithSubtype:subtypeString ForView:self.view]; break; case PageCurl: [self transitionWithType:@"pageCurl" WithSubtype:subtypeString ForView:self.view]; break; case PageUnCurl: [self transitionWithType:@"pageUnCurl" WithSubtype:subtypeString ForView:self.view]; break; case CameraIrisHollowOpen: [self transitionWithType:@"cameraIrisHollowOpen" WithSubtype:subtypeString ForView:self.view]; break; case CameraIrisHollowClose: [self transitionWithType:@"cameraIrisHollowClose" WithSubtype:subtypeString ForView:self.view]; break; case CurlDown: [self animationWithView:self.view WithAnimationTransition:UIViewAnimationTransitionCurlDown]; break; case CurlUp: [self animationWithView:self.view WithAnimationTransition:UIViewAnimationTransitionCurlUp]; break; case FlipFromLeft: [self animationWithView:self.view WithAnimationTransition:UIViewAnimationTransitionFlipFromLeft]; break; case FlipFromRight: [self animationWithView:self.view WithAnimationTransition:UIViewAnimationTransitionFlipFromRight]; break; default: break; } static int i = 0; if (i == 0) { [self addBgImageWithImageName:IMAGE1]; i = 1; } else { [self addBgImageWithImageName:IMAGE2]; i = 0; } }
#pragma CATransition动画实现 - (void) transitionWithType:(NSString *)type WithSubtype:(NSString *) subtype ForView : (UIView *) view { //创建CATransition对象 CATransition * animation = [CATransition animation]; //设置运动时间 animation.duration = DURATION; //设置运动type animation.type = type; if (subtype != nil) { //设置子类 animation.subtype = subtype; } //设置运动速度 animation.timingFunction = UIViewAnimationOptionCurveEaseInOut; [view.layer addAnimation:animation forKey:@"animation"]; } #pragma UIView实现动画 - (void) animationWithView:(UIView *)view WithAnimationTransition : (UIViewAnimationTransition) transition { [UIView animateWithDuration:DURATION animations:^{ [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationTransition:transition forView:view cache:YES]; }]; }
相关文章推荐
- 简单东西-group by与sum一起进行数据统计
- Xcode encountered a problem. Source editor functionality is limited. Attempting to restore...
- PHP 运行方式(PHP SAPI介绍)
- cocos2dx-lua里面class的实现的一些问题记录和思考
- Android PopupWindow简单使用
- InnoDB体系结构
- MongoDB快速入门(十三)- 聚合count、distinct和group
- 获取鼠标按键事件
- 简单工厂和单例的一些事
- 光标位置插入内容
- iOS SVProgressHUD延迟提示显示时间的方法
- Kafka深度解析
- 0x0000006B蓝屏问题解决方法
- Instant Run 浅析
- 使用第三方工具Cornerstone搭建本地SVN服务器
- Warning[w6]
- nil coalescing operator
- build path功能详解
- mac shell命令连接mongo
- Android上传头像代码,相机,相册,裁剪