您的位置:首页 > 产品设计 > UI/UE

UIview简单动画

2012-09-13 21:11 309 查看
//简单移动

imageView.transform =
CGAffineTransformIdentity;
imageView.frame=CGRectMake(0, 100, 320, 320);
[UIView beginAnimations:@"clearmemory"context:imageView];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(enablebutton)];
imageView.frame=CGRectMake(34, 0, 320, 320);
[UIView commitAnimations];

//动画曲线

[UIView beginAnimations:nilcontext:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
// UIViewAnimationCurveEaseInOut, // slow at beginning and end
//UIViewAnimationCurveEaseIn, // slow at beginning
//UIViewAnimationCurveEaseOut, // slow at end
//UIViewAnimationCurveLinear //恒定速度
[UIView setAnimationDidStopSelector:@selector(enablebutton:)];
imageView.frame=CGRectMake(22, 0, 320, 320);
[UIView commitAnimations];

//反向重复

[UIView beginAnimations:@"animation3" context:imageView1];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:1.0];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationRepeatCount:10];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(enablebutton:)];
imageView1.alpha=0;
[UIView commitAnimations];

// 延时,缓入,缓出

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:0.5];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];

[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationRepeatCount:2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(enablebutton:)];
imageView.frame=CGRectMake(120, 0, 200, 200);
[UIView commitAnimations];

//缓出
[UIView beginAnimations:nilcontext:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(enablebutton:)];
imageView.frame =CGRectMake(235, 144, 200 , 200);
[UIView commitAnimations];

//放大
[UIView beginAnimations:nilcontext:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(enablebutton:)];
imageView.transform=CGAffineTransformMakeScale(2, 2);
[UIView commitAnimations];
//旋转放大这里用到179.9是因为你不管前面加-+都是逆时针
[UIView beginAnimations:nilcontext:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(enablebutton:)];
CGAffineTransform tranform1=CGAffineTransformMakeScale(1, 1);
CGAffineTransform tranform3=CGAffineTransformMakeTranslation(200, 200);
CGAffineTransform tranform2=CGAffineTransformMakeRotation(179.9*M_PI/180.0);
imageView.transform =CGAffineTransformConcat(tranform1, tranform3);
[UIView commitAnimations];

//平移旋转

[UIView beginAnimations:nilcontext:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(enablebutton:)];
CGAffineTransform tranform1=CGAffineTransformMakeTranslation(-200, 0);
// CGAffineTransform tranform2= CGAffineTransformMakeRotation(179.9*M_PI/180.0);
imageView.transform =CGAffineTransformRotate(tranform1, 359.9*M_PI/180.0);
[UIView commitAnimations];
//翻转
[UIView beginAnimations:nilcontext:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRightforView:self.viewcache:YES];
//UIViewAnimationTransitionFlipFromLeft 从左往右翻
//UIViewAnimationTransitionFlipFromRight从右往左翻
//UIViewAnimationTransitionCurlUp
从上往下翻
//UIViewAnimationTransitionCurlDown
从下往上翻
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(enablebutton:)];
imageView.hidden=YES;
imageView1.hidden=NO;
[UIView commitAnimations];

//淡入淡出
CATransition *animation = [CATransition
animation];
animation.duration = 0.75f;
//动画时长
animation.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseIn];
animation.delegate = self;
animation.type = kCATransitionFade;
//过度效果
//kCATransitionFade 淡入淡出
//kCATransitionMoveIn 移入移出
//kCATransitionPush 压入推出
//kCATransitionReveal 覆盖移除
animation.subtype=kCATransitionFromLeft;
//kCATransitionFromRight 从左
//kCATransitionFromLeft 从右
//kCATransitionFromTop 从上
//kCATransitionFromBottom 从下
[self.view.layer
addAnimation:animation forKey:@"animation"];
imageView.hidden=YES;
imageView1.hidden=NO;

-(void)enablebutton:(id)sender
{
imageView.transform=CGAffineTransformIdentity;
imageView.frame=CGRectMake(0, 0, 200, 200);
//btn.enabled=NO;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: