读书人

UIview容易动画

发布时间: 2012-09-18 16:21:42 作者: rapoo

UIview简单动画


//简单移动

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

-(void)enablebutton:(id)sender

{

imageView.transform=CGAffineTransformIdentity;

imageView.frame=CGRectMake(0, 0, 200, 200);

//btn.enabled=NO;

}





读书人网 >移动开发

热点推荐