//第一种动画方式
- (void) first_animations
{
[UIView beginAnimations:nilcontext:nil]; //启动动画动作
[UIView setAnimationRepeatCount:1];//设置是否重复播放
[UIView setAnimationDuration:1];//设置动画持续时间
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];//动画曲线,具体的应用 ,可以经过实验检测
[UIView setAnimationDelegate:self];//动画块的某个方法(最下方),委托到本类的实例
[UIView setAnimationDidStopSelector:@selector(resetView)];//动画结束后去执行的方法
CGAffineTransform oneTransform = CGAffineTransformRotate(self.animatView.transform, degreesToRadian(180));//进行 CGAffineTransform 方式的动作(旋转拉伸等等)===>(对于CGAffineTransform 可以另外开辟一个关于CGAffineTransform使用详情的文章进行专门介绍 )
CGAffineTransform twoTransform = CGAffineTransformTranslate(self.animatView.transform,0,-100);
CGAffineTransform newTransform = CGAffineTransformConcat(oneTransform, twoTransform);
[self.animatView setTransform:newTransform];
[UIViewcommitAnimations];//有些网友说,这是动画结束.起始经过本人尝试试验.其实应该是,执行上方定义的动画块内容.
}
//第二中动画定义方式
- (void) second_animations
{
CABasicAnimation *animation = [CABasicAnimationanimationWithKeyPath:@"opacity"];
[animationsetDuration:1];
[animationsetRepeatCount:0];
[animationsetAutoreverses:YES];//自动反向动画
[animation setFromValue:[NSNumbernumberWithFloat:1.0]];
[animation setToValue:[NSNumbernumberWithFloat:0]];
[animationsetDelegate:self];
[self.animatView.layer addAnimation:animation forKey:@"firstView-Opacity"];
}
- (void) third_animations
{
[UIView beginAnimations:nilcontext:nil];
[UIView setAnimationRepeatCount:1];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.containView cache:YES];
[UIViewsetAnimationDidStopSelector:@selector(animationDidStop:finished:)];
[UIView commitAnimations];
}
- (void) fourth_animations
{
CATransition *transition = [CATransitionanimation];
transition.duration = 1.0f; /* 间隔时间*/
transition.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut]; /* 动画的开始与结束的快慢*/
transition.type =@"pageCurl"; //@"cube" @"moveIn" @"reveal" @"fade"(default) @"pageCurl" @"pageUnCurl" @"suckEffect" @"rippleEffect" @"oglFlip"
transition.subtype =kCATransitionFromRight;
transition.removedOnCompletion =YES;
transition.fillMode =kCAFillModeBackwards;
transition.delegate =self;
[self.animatView.layer addAnimation:transition forKey:nil];
}
-(void) resetView
{
[self.animatView setTransform:CGAffineTransformRotate(self.animatView.transform, degreesToRadian(180))];
self.animatView.frame = CGRectMake(0, 0, 280, 200);
}
#pragma mark Delegate Methods
- (void)animationDidStop:(CAAnimation *) theAnimation finished:(BOOL) flag {
self.animatView.frame = CGRectMake(0, 0, 280, 200);
}
#define degreesToRadian(x) (M_PI * (x) / 180.0)