系统的动画 有:
// 设定动画类型
// kCATransitionFade 淡化
// kCATransitionPush 推挤
// kCATransitionReveal 揭开
// kCATransitionMoveIn 覆盖
// @"cube" 立方体
// @"suckEffect" 吸收
// @"oglFlip" 翻转
// @"rippleEffect" 波纹
// @"pageCurl" 翻页
// @"pageUnCurl" 反翻页
// @"cameraIrisHollowOpen" 镜头开
// @"cameraIrisHollowClose" 镜头关
使用: 上翻 、下翻、 左翻 、 右翻
#pragma mark 控制方向
- (IBAction)buttonDirection:(id)sender
{
UIButton *button = (UIButton *)sender;
NSInteger tag = button.tag;
// 使用UIView创建动画
// 开始设置动画
CGContextRef context = UIGraphicsGetCurrentContext();
// 动画开始
[UIView beginAnimations:nil context:context];
// 设置动画快慢
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
// 设置动画时间
[UIView setAnimationDuration:kDuration];
// 4种类型
switch (tag) {
case 105:
// 设置动画类型
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
break;
case 106:
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
break;
case 107:
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
break;
case 108:
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
break;
default:
break;
}
// 视图切换,请替换以下三行代码
NSUInteger bt1 = [[self.view subviews] indexOfObject:self.xBt1View];
NSUInteger bt2 = [[self.view subviews] indexOfObject:self.xBt2View];
[self.view exchangeSubviewAtIndex:bt1 withSubviewAtIndex:bt2];
[UIView setAnimationDelegate:self];
// 动画完毕后调用某个方法
//[UIView setAnimationDidStopSelector:@selector(animationFinished:)];
// 提交动画
[UIView commitAnimations];
}
使用: 淡化 、 推挤 、 揭开 、 覆盖 、 立方体 、 吸收 、 翻转 、 波纹 、 翻页 、 反翻页 、 镜头开 、 镜头关 、
#pragma mark 动画功能
- (IBAction)buttonFunction:(id)sender
{
UIButton *button = (UIButton *)sender;
NSInteger tag = button.tag;
// 使用Core Animation创建动画
// 创建CATransition对象
CATransition *animation = [CATransition animation];
animation.delegate = self;
// 设定动画时间
animation.duration = kDuration;
// 设定动画快慢(开始与结束时较慢)
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
// 12种类型
switch (tag) {
case 101:
// 设定动画类型
// kCATransitionFade 淡化
// kCATransitionPush 推挤
// kCATransitionReveal 揭开
// kCATransitionMoveIn 覆盖
// @"cube" 立方体
// @"suckEffect" 吸收
// @"oglFlip" 翻转
// @"rippleEffect" 波纹
// @"pageCurl" 翻页
// @"pageUnCurl" 反翻页
// @"cameraIrisHollowOpen" 镜头开
// @"cameraIrisHollowClose" 镜头关
animation.type = kCATransitionFade;
break;
case 102:
animation.type = kCATransitionPush;
break;
case 103:
animation.type = kCATransitionReveal;
break;
case 104:
animation.type = kCATransitionMoveIn;
break;
case 201:
animation.type = @"cube";
break;
case 202:
animation.type = @"suckEffect";
break;
case 203:
animation.type = @"oglFlip";
break;
case 204:
animation.type = @"rippleEffect";
break;
case 205:
animation.type = @"pageCurl";
break;
case 206:
animation.type = @"pageUnCurl";
break;
case 207:
animation.type = @"cameraIrisHollowOpen";
break;
case 208:
animation.type = @"cameraIrisHollowClose";
break;
default:
break;
}
// 四个方向
switch (self.typeID) {
case 0:
// 设定动画方向
animation.subtype = kCATransitionFromLeft;
break;
case 1:
animation.subtype = kCATransitionFromBottom;
break;
case 2:
animation.subtype = kCATransitionFromRight;
break;
case 3:
animation.subtype = kCATransitionFromTop;
break;
default:
break;
}
self.typeID += 1;
if (self.typeID > 3) {
self.typeID = 0;
}
// 视图切换,请替换以下三行代码
NSUInteger bt1 = [[self.view subviews] indexOfObject:self.xBt1View];
NSUInteger bt2 = [[self.view subviews] indexOfObject:self.xBt2View];
[self.view exchangeSubviewAtIndex:bt1 withSubviewAtIndex:bt2];
// 动画开始
[[self.view layer] addAnimation:animation forKey:@"animation"];
}
#pragma mark CAAnimationDelegate
// 动画开始时调用
- (void)animationDidStart:(CAAnimation *)anim
{
NSLog(@"animationDidStart");
}
// 动画结束时调用
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
NSLog(@"animationDidStop");
}
//返回
- (IBAction)xReturn:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
系统的动画 有:
// 设定动画类型
// kCATransitionFade 淡化
// kCATransitionPush 推挤
// kCATransitionReveal 揭开
// kCATransitionMoveIn 覆盖
// @"cube" 立方体
// @"suckEffect" 吸收
// @"oglFlip" 翻转
// @"rippleEffect" 波纹
// @"pageCurl" 翻页
// @"pageUnCurl" 反翻页
// @"cameraIrisHollowOpen" 镜头开
// @"cameraIrisHollowClose" 镜头关
使用: 上翻 、下翻、 左翻 、 右翻
#pragma mark 控制方向
- (IBAction)buttonDirection:(id)sender
{
UIButton *button = (UIButton *)sender;
NSInteger tag = button.tag;
// 使用UIView创建动画
// 开始设置动画
CGContextRef context = UIGraphicsGetCurrentContext();
// 动画开始
[UIView beginAnimations:nil context:context];
// 设置动画快慢
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
// 设置动画时间
[UIView setAnimationDuration:kDuration];
// 4种类型
switch (tag) {
case 105:
// 设置动画类型
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
break;
case 106:
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
break;
case 107:
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
break;
case 108:
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
break;
default:
break;
}
// 视图切换,请替换以下三行代码
NSUInteger bt1 = [[self.view subviews] indexOfObject:self.xBt1View];
NSUInteger bt2 = [[self.view subviews] indexOfObject:self.xBt2View];
[self.view exchangeSubviewAtIndex:bt1 withSubviewAtIndex:bt2];
[UIView setAnimationDelegate:self];
// 动画完毕后调用某个方法
//[UIView setAnimationDidStopSelector:@selector(animationFinished:)];
// 提交动画
[UIView commitAnimations];
}
使用: 上翻 、下翻、 左翻 、 右翻 #pragma mark 控制方向 - (IBAction)buttonDirection:(id)sender { UIButton *button = (UIButton *)sender; NSInteger tag = button.tag; // 使用UIView创建动画 // 开始设置动画 CGContextRef context = UIGraphicsGetCurrentContext(); // 动画开始 [UIView beginAnimations:nil context:context]; // 设置动画快慢 [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; // 设置动画时间 [UIView setAnimationDuration:kDuration]; // 4种类型 switch (tag) { case 105: // 设置动画类型 [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES]; break; case 106: [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; break; case 107: [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES]; break; case 108: [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES]; break; default: break; } // 视图切换,请替换以下三行代码 NSUInteger bt1 = [[self.view subviews] indexOfObject:self.xBt1View]; NSUInteger bt2 = [[self.view subviews] indexOfObject:self.xBt2View]; [self.view exchangeSubviewAtIndex:bt1 withSubviewAtIndex:bt2]; [UIView setAnimationDelegate:self]; // 动画完毕后调用某个方法 //[UIView setAnimationDidStopSelector:@selector(animationFinished:)]; // 提交动画 [UIView commitAnimations]; }
使用: 淡化 、 推挤 、 揭开 、 覆盖 、 立方体 、 吸收 、 翻转 、 波纹 、 翻页 、 反翻页 、 镜头开 、 镜头关 、
#pragma mark 动画功能
- (IBAction)buttonFunction:(id)sender
{
UIButton *button = (UIButton *)sender;
NSInteger tag = button.tag;
// 使用Core Animation创建动画
// 创建CATransition对象
CATransition *animation = [CATransition animation];
animation.delegate = self;
// 设定动画时间
animation.duration = kDuration;
// 设定动画快慢(开始与结束时较慢)
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
// 12种类型
switch (tag) {
case 101:
// 设定动画类型
// kCATransitionFade 淡化
// kCATransitionPush 推挤
// kCATransitionReveal 揭开
// kCATransitionMoveIn 覆盖
// @"cube" 立方体
// @"suckEffect" 吸收
// @"oglFlip" 翻转
// @"rippleEffect" 波纹
// @"pageCurl" 翻页
// @"pageUnCurl" 反翻页
// @"cameraIrisHollowOpen" 镜头开
// @"cameraIrisHollowClose" 镜头关
animation.type = kCATransitionFade;
break;
case 102:
animation.type = kCATransitionPush;
break;
case 103:
animation.type = kCATransitionReveal;
break;
case 104:
animation.type = kCATransitionMoveIn;
break;
case 201:
animation.type = @"cube";
break;
case 202:
animation.type = @"suckEffect";
break;
case 203:
animation.type = @"oglFlip";
break;
case 204:
animation.type = @"rippleEffect";
break;
case 205:
animation.type = @"pageCurl";
break;
case 206:
animation.type = @"pageUnCurl";
break;
case 207:
animation.type = @"cameraIrisHollowOpen";
break;
case 208:
animation.type = @"cameraIrisHollowClose";
break;
default:
break;
}
// 四个方向
switch (self.typeID) {
case 0:
// 设定动画方向
animation.subtype = kCATransitionFromLeft;
break;
case 1:
animation.subtype = kCATransitionFromBottom;
break;
case 2:
animation.subtype = kCATransitionFromRight;
break;
case 3:
animation.subtype = kCATransitionFromTop;
break;
default:
break;
}
self.typeID += 1;
if (self.typeID > 3) {
self.typeID = 0;
}
// 视图切换,请替换以下三行代码
NSUInteger bt1 = [[self.view subviews] indexOfObject:self.xBt1View];
NSUInteger bt2 = [[self.view subviews] indexOfObject:self.xBt2View];
[self.view exchangeSubviewAtIndex:bt1 withSubviewAtIndex:bt2];
// 动画开始
[[self.view layer] addAnimation:animation forKey:@"animation"];
}
#pragma mark CAAnimationDelegate
// 动画开始时调用
- (void)animationDidStart:(CAAnimation *)anim
{
NSLog(@"animationDidStart");
}
// 动画结束时调用
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
NSLog(@"animationDidStop");
}
//返回
- (IBAction)xReturn:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}