欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

iOS 动画(3)

程序员文章站 2023-01-13 15:13:10
ios 动画。 catransition动画设置两个uiview uiview *magentaview =[[uiview alloc]initwithframe:self.view.bounds...

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