你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS 動畫(3)

iOS 動畫(3)

編輯:IOS開發綜合

iOS 動畫。

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];
}

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved