QuartzCore框架 CATransition动画
来源:互联网 发布:广西农产品出口数据 编辑:程序博客网 时间:2024/06/05 11:41
#define kBackgroundColor1 [UIColor redColor]#define kBackgroundColor2 [UIColor yellowColor]#define kDurationTime 0.7f@interface ViewController ()@property (nonatomic,assign) int subType;@endtypedef enum : NSUInteger{ Fade = 1, //淡入淡出 Push, //推挤 Reveal, //揭开 MoveIn, //覆盖 Cube, //立方体 SuckEffect, //吸附 OglFlip, //翻转 RippleEffect, //波纹 PageCurl, //翻页 PageUnCurl, //反翻页 CameraIrisHollowOpen, //开镜头 CameraIrisHollowClose, //关镜头 CurlDown, //下翻转 CurlUp, //上翻转 FlipFromLeft, //左翻转 FlipFromRight, //右翻转 }AnimationType;@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; self.subType = 0; [self showViewBgWithName:kBackgroundColor2]; }- (IBAction)tagButtonAction:(id)sender { UIButton *button = sender; AnimationType animationType = button.tag; NSString *subtypeString; // 设置方向 switch (self.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; } // QuartzCore 动画 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 showViewBgWithName:kBackgroundColor1]; i = 1; }else{ [self showViewBgWithName:kBackgroundColor2]; i = 0; }}- (void)showViewBgWithName:(UIColor *)color{ self.view.backgroundColor = color;}#pragma mark CATransition 动画实现- (void)transitionWithType:(NSString *)type WithSubtype:(NSString *)subType ForView:(UIView *)View{ //创建Catransition对象 CATransition *animation = [CATransition animation]; //设置运动时间 animation.duration = kDurationTime; //设置运动type animation.type = type; if (subType != nil) { // 设置子类 animation.subtype = subType; } // 设置运动速度 animation.timingFunction = UIViewAnimationOptionCurveEaseInOut; [View.layer addAnimation:animation forKey:@"animation"]; }#pragma mark UIView 实现动画- (void)animationWithView:(UIView *)view WithAnimationTransition:(UIViewAnimationTransition)transition{ [UIView animateWithDuration:kDurationTime animations:^{ [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationTransition:transition forView:view cache:YES]; }];}@end
0 0
- QuartzCore框架 CATransition动画
- QuartzCore框架-- iOS中的动画
- iOS ——QuartzCore核心动画框架
- ios--Quartzcore核心动画框架的学习
- QuartzCore/QuartzCore框架
- QuartzCore框架
- QuartzCore框架
- CATransition 动画
- CATransition动画
- CATransition动画
- iOS动画 CATransition动画
- iOS之QuartzCore框架
- QuartzCore框架学习-CADisplayLink
- QuartzCore框架学习-CAEmitterLayer
- QuartzCore框架学习-CAGradientLayer
- QuartzCore框架简介
- QuartzCore 之 CAAnimation 动画详解
- iOS 动画初探序一:QuartzCore框架与CoreAnimation的前世今生
- storm 学习教程
- MongoDB基本使用和操作
- 使用JDK自带的方法进行文件压缩
- vi删除 复制 替换
- struts2文件上传
- QuartzCore框架 CATransition动画
- 设计模式之个人见解
- 推荐系统_LFM和基于邻域(如UserCF、ItemCF)的方法的比较
- 二分图最大权匹配--KM算法模板
- 论文阅读记录: Automatic Image Colorization sig16
- java和objective-C对接笔记
- 基于Redis Sentinel的Redis集群(主从&Sharding)高可用方案
- 数组和广义表的基本运算实现(三元组)
- 图的邻接表 表示 DFS 和BFS C++实现