//第一種動畫方式
- (void) first_animations
{
[UIView beginAnimations:nil context: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];
[UIView commitAnimations];//有些網友說,這是動畫結束.起始經過本人嘗試試驗.其實應該是,執行上方定義的動畫塊內容.
}
//第二中動畫定義方式
- (void) second_animations
{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
[animation setDuration:1];
[animation setRepeatCount:0];
[animation setAutoreverses:YES];//自動反向動畫
[animation setFromValue:[NSNumber numberWithFloat:1.0]];
[animation setToValue:[NSNumber numberWithFloat:0]];
[animation setDelegate:self];
[self.animatView.layer addAnimation:animation forKey:@"firstView-Opacity"];
}
- (void) third_animations
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationRepeatCount:1];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.containView cache:YES];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:)];
[UIView commitAnimations];
}
- (void) fourth_animations
{
CATransition *transition = [CATransition animation];
transition.duration = 1.0f; /* 間隔時間*/
transition.timingFunction = [CAMediaTimingFunction functionWithName: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)
================再次挖井的分割線07.11=============
