iOS 动画(3)
2017-02-24 23:14
141 查看
CATransition动画设置两个UIView
UIView *magentaView =[[UIView alloc]initWithFrame:self.view.bounds];
magentaView.backgroundColor =[UIColor magentaColor];
[self.view addSubview:magentaView];
UIView * gtayView =[[UIView alloc]initWithFrame:self.view.bounds];
gtayView.backgroundColor =[UIColor lightGrayColor];
[self.view addSubview:gtayView];
//提交
-(void)add{
// 开始动画
[UIView beginAnimations:@"animation" context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
// 提交动画
[UIView commitAnimations];
}
//翻页
-(void)curl
{
// 开始动画
[UIView beginAnimations:@"animation" context:nil];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
// 提交动画
[UIView commitAnimations];
}
//移入
-(void)move
{
CATransition *strasiton =[CATransition animation];
strasiton.duration = 2.0f;
// 使用kCATransitionMoveIn动画
strasiton.type = kCATransitionMoveIn;
// 指定动画方向,从左向右
strasiton.subtype = kCATransitionFromLeft;
[self.view.layer addAnimation:strasiton forKey:@"animation"];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
}
//揭开
-(void)reveal
{
CATransition *strasiton =[CATransition animation];
strasiton.duration = 2.0f;
// 使用kCATransitionReveal动画
strasiton.type = kCATransitionReveal;
strasiton.subtype = kCATransitionFromTop;
[self.view.layer addAnimation:strasiton forKey:@"animation"];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
}
//立方体
-(void)cube
{
CATransition *trasiton =[CATransition animation];
trasiton.duration = 2.0f;
trasiton.type = @"cube";
trasiton.subtype = kCATransitionFromLeft;
[self.view.layer addAnimation:trasiton forKey:@"animation"];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
}
//吸入
-(void)suck
{
CATransition *trasiton =[CATransition animation];
trasiton.duration = 2.0f;
trasiton.type = @"suckEffect";
trasiton.subtype = kCATransitionFromLeft;
[self.view.layer addAnimation:trasiton forKey:@"animation"];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
}
//翻转
-(void)oglFlip
{
CATransition *trasiton =[CATransition animation];
trasiton.duration = 2.0f;
trasiton.type = @"oglFlip";
trasiton.subtype = kCATransitionFromLeft;
[self.view.layer addAnimation:trasiton forKey:@"animation"];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
}
//水波
-(void)ripple
{
CATransition *trasiton =[CATransition animation];
trasiton.duration = 2.0f;
trasiton.type = @"rippleEffect";
trasiton.subtype = kCATransitionFromLeft;
[self.view.layer addAnimation:trasiton forKey:@"animation"];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
}
UIView *magentaView =[[UIView alloc]initWithFrame:self.view.bounds];
magentaView.backgroundColor =[UIColor magentaColor];
[self.view addSubview:magentaView];
UIView * gtayView =[[UIView alloc]initWithFrame:self.view.bounds];
gtayView.backgroundColor =[UIColor lightGrayColor];
[self.view addSubview:gtayView];
//提交
-(void)add{
// 开始动画
[UIView beginAnimations:@"animation" context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
// 提交动画
[UIView commitAnimations];
}
//翻页
-(void)curl
{
// 开始动画
[UIView beginAnimations:@"animation" context:nil];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
// 提交动画
[UIView commitAnimations];
}
//移入
-(void)move
{
CATransition *strasiton =[CATransition animation];
strasiton.duration = 2.0f;
// 使用kCATransitionMoveIn动画
strasiton.type = kCATransitionMoveIn;
// 指定动画方向,从左向右
strasiton.subtype = kCATransitionFromLeft;
[self.view.layer addAnimation:strasiton forKey:@"animation"];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
}
//揭开
-(void)reveal
{
CATransition *strasiton =[CATransition animation];
strasiton.duration = 2.0f;
// 使用kCATransitionReveal动画
strasiton.type = kCATransitionReveal;
strasiton.subtype = kCATransitionFromTop;
[self.view.layer addAnimation:strasiton forKey:@"animation"];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
}
//立方体
-(void)cube
{
CATransition *trasiton =[CATransition animation];
trasiton.duration = 2.0f;
trasiton.type = @"cube";
trasiton.subtype = kCATransitionFromLeft;
[self.view.layer addAnimation:trasiton forKey:@"animation"];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
}
//吸入
-(void)suck
{
CATransition *trasiton =[CATransition animation];
trasiton.duration = 2.0f;
trasiton.type = @"suckEffect";
trasiton.subtype = kCATransitionFromLeft;
[self.view.layer addAnimation:trasiton forKey:@"animation"];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
}
//翻转
-(void)oglFlip
{
CATransition *trasiton =[CATransition animation];
trasiton.duration = 2.0f;
trasiton.type = @"oglFlip";
trasiton.subtype = kCATransitionFromLeft;
[self.view.layer addAnimation:trasiton forKey:@"animation"];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
}
//水波
-(void)ripple
{
CATransition *trasiton =[CATransition animation];
trasiton.duration = 2.0f;
trasiton.type = @"rippleEffect";
trasiton.subtype = kCATransitionFromLeft;
[self.view.layer addAnimation:trasiton forKey:@"animation"];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
}
相关文章推荐
- 【iOS-Cocos2d游戏开发之七】在cocos2d中添加/删除系统组件,并解决View设置透明会影响View中的其他组件的问题!【11月28日更新解决添加组件Cocos2d动画停止播放的BUG】
- iOS-实现简单的动画效果
- iOS-实现简单的动画效果
- 【iOS-Cocos2d游戏开发之二十二 】CCSpeed实现CCAnimate动画进行时设置慢动作以及设置游戏加减速进行(塔防游戏必备)! .
- iOS动画:Core Animation概述
- ios中view的动画效果
- 【iOS-Cocos2d游戏开发之二十一 】自定义精灵类并为你的精灵设置攻击帧(指定开始帧)以及扩展Cocos2d源码的CCAnimation简化动画创建!
- 【iOS-Cocos2d游戏开发之二十二 】CCSpeed实现动画进行时慢动作\设置游戏加减速进行
- 【iOS-Cocos2d游戏开发之二十二 】CCSpeed实现CCAnimate动画进行时设置慢动作以及设置游戏加减速进行(塔防游戏必备)! .
- ios 视图切换动画效果
- IOS中如何模拟UINavigationController的Slide动画
- iphone ios 动画
- 【iOS-Cocos2d游戏开发之十八】解决滚屏背景/拼接地图有黑边(缝隙)/动画播放出现毛边以及禁止游戏中自动锁屏问题!【2011年12月18日补充】
- ios 视图切换动画效果
- ios中view的动画效果
- [iOS]实现了一套自定义动画库
- RAD Studio XE2新特性概览:多平台支持、原生iOS与Android、HD与3D动画及云
- 【iOS-Cocos2d游戏开发之二十一 】自定义精灵类并为你的精灵设置攻击帧以及动画创建!【一】
- ios 视图切换动画效果
- 如何在ios中运用core animation暂停和继续动画