ios 學習總結之動畫

CAlaye的動畫動畫

 //建立CAlayer動畫url

     CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"bounds.size"];代理

    //設置初始大小ip

[animation setFromValue:[NSValue valueWithCGSize:CGSizeMake(1.0, 1.0)]];ci

    //設置運行後的方法rem

[animation setToValue:[NSValue  valueWithCGSize:manImageView.bounds.size]];animation

    //設置時常it

[animation  setDuration:1.2];io

    //設子代理監聽方法

    [animation setDelegate:self];

[manImageView.layer  addAnimation:animation forKey:@"image-bounds.size"];

 

 

 

//漂浮的動畫

 

 CAKeyframeAnimation  *animation=[CAKeyframeAnimation animationWithKeyPath:@"position"];

    //設置view行動的軌跡

    NSArray *values=[NSArray arrayWithObjects:[NSValue valueWithCGPoint:CGPointMake(fx,fy)],

[NSValue valueWithCGPoint:CGPointMake(fx1, fy1)],

[NSValue valueWithCGPoint:CGPointMake(fx2, fy2)],

[NSValue valueWithCGPoint:CGPointMake(fx3, fy3)],

[NSValue valueWithCGPoint:CGPointMake(fx4, fy4)],nil];

//得到點

[animation setValues:values];

    //設置時常

[animation setDuration:5.0];

    //設置代理監聽

    [animation setDelegate:self];

[manImageView.layer  addAnimation:animation forKey:@"img-position"];

 

 

//漸變的動畫

 

 

    CABasicAnimation * animation=[CABasicAnimation  animationWithKeyPath:@"opacity"];

    //設置透明度最小值

[animation setFromValue:[NSNumber numberWithFloat:1.0]];

    //設置透明度最大值

    [animation setToValue:[NSNumber numberWithInt:0.0]];

    //播放速率

    [animation setDuration:3.0];

    //播放次數

[animation setRepeatCount:3.0];

    //設置監聽代理

    [animation setDelegate:self];

[animation setAutoreverses:YES];//默認的是NO,即透明完畢後立馬恢復,YES是延遲恢復

    [manImageView.layer  addAnimation:animation forKey:@"img-opacity"];

 

//立方體的動畫

 

 

 CATransition *animation = [CATransition animation];

         //動畫名稱

            animation.type =@"cube";

     //翻轉方向

            animation.subtype = kCATransitionFromLeft;

      //時長

            [animation setDuration:2];

    //代理方法

            [animation setDelegate:self];

    //上一個動畫播放完不移除,默認是YES移除

            animation.removedOnCompletion = NO;

            [_bView.layer addAnimation:animation forKey:@"docube"];

 

//水波紋動畫

 

 

CATransition *animation = [CATransition animation];

            animation.type =@"rippleEffect";

            [animation setDuration:2];

            [animation setRepeatCount:1.0];

            [_bView.layer addAnimation:animation forKey:@"s rippleEffect"];

//收縮效果

 

 

CATransition *animation = [CATransition animation];

            animation.type =@"suckEffect";

            [animation setDuration:2];

            [animation setRepeatCount:1.0];

            [_bView.layer addAnimation:animation forKey:@"s suckEffect"];

 

//向後翻轉動畫

 

CATransition *animation = [CATransition animation];

            animation.type =@"oglFlip";

            [animation setDuration:2];

            [animation setRepeatCount:1.0];

            [_bView.layer addAnimation:animation forKey:@"s oglFlip"];

 

//向上翻頁的動畫

 

 

CATransition *animation = [CATransition animation];

            animation.type =@"pageCurl";

            [animation setDuration:2];

            [animation setRepeatCount:1.0];

            [_bView.layer addAnimation:animation forKey:@"s pageCurl"];

 

跟上邊效果相反的動畫

 

CATransition *animation = [CATransition animation];

            animation.type =@"pageUnCurl「;

            [animation setDuration:2];

            [animation setRepeatCount:1.0];

          

 

[_bView.layer addAnimation:animation forKey:@"s pageUnCurl"];

這些動畫效果跟上邊的用法同樣

新視圖覆蓋舊視圖

 

moveIn

舊視圖移出露出新視圖

 

reveal

新視圖把舊視圖推出去

 

push

立方體向上滾動

alignedCube

相機動畫

cameraIris

相機打開效果

 

cameraIrisHollowOpen

相機關閉效果

 

cameraIrisHollowClose

 

* 過渡方向fromRight;fromLeft;fromTop;fromBottom;

相關文章
相關標籤/搜索