iOS 基礎(chǔ)動(dòng)畫

iOS的動(dòng)畫效果一直都很棒很,給人的感覺就是很炫酷很流暢,起到增強(qiáng)用戶體驗(yàn)的作用。在APP開發(fā)中實(shí)現(xiàn)動(dòng)畫效果有很多種方式,對(duì)于簡單的應(yīng)用場(chǎng)景,我們可以使用UIKit提供的動(dòng)畫來實(shí)現(xiàn)。

UIView動(dòng)畫

UIView動(dòng)畫實(shí)質(zhì)上是對(duì)CoreAnimation的封裝,iOS4.0以后,增加了Block動(dòng)畫塊,提供更簡潔的方式來實(shí)現(xiàn)動(dòng)畫。

共有六個(gè)常見的Block動(dòng)畫方法:
  • 1、最簡單的Block動(dòng)畫,包含時(shí)間和動(dòng)畫[UIView animateWithDuration:<#(NSTimeInterval)#> animations:<#^(void)animations#>];

  • 2、帶有動(dòng)畫完成回調(diào)的Block動(dòng)畫 [UIView animateWithDuration:<#(NSTimeInterval)#> animations:<#^(void)animations#> completion:<#^(BOOL finished)completion#>];

  • 3、可設(shè)置延遲時(shí)間和過渡效果的Block動(dòng)畫 ``[UIView animateWithDuration:<#(NSTimeInterval)#> delay:<#(NSTimeInterval)#> options:<#(UIViewAnimationOptions)#> animations:<#^(void)animations#> completion:<#^(BOOL finished)completion#>]

  • 4、Spring動(dòng)畫,iOS7.0后新增Spring動(dòng)畫(iOS系統(tǒng)動(dòng)畫大部分采用SpringAnimation,適用于所有可被添加動(dòng)畫效果的屬性)[UIView animateWithDuration:<#(NSTimeInterval)#> delay:<#(NSTimeInterval)#> usingSpringWithDamping:<#(CGFloat)#> initialSpringVelocity:<#(CGFloat)#> options:<#(UIViewAnimationOptions)#> animations:<#^(void)animations#> completion:<#^(BOOL finished)completion#>]

  • 5、Keyframes動(dòng)畫,iOS7.0后新增關(guān)鍵幀動(dòng)畫,支持屬性關(guān)鍵幀,不支持路徑關(guān)鍵幀 [UIView animateKeyframesWithDuration:<#(NSTimeInterval)#> delay:<#(NSTimeInterval)#> options:<#(UIViewKeyframeAnimationOptions)#> animations:<#^(void)animations#> completion:<#^(BOOL finished)completion#>]

  • 6、轉(zhuǎn)場(chǎng)動(dòng)畫

    • 從舊視圖轉(zhuǎn)到新視圖的動(dòng)畫效果,在該動(dòng)畫過程中,fromView會(huì)從父視圖中移除,并講toView添加到父視圖中,注意轉(zhuǎn)場(chǎng)動(dòng)畫的作用對(duì)象是父視圖(過渡效果體現(xiàn)在父視圖上)[UIView transitionFromView:<#(nonnull UIView *)#> toView:<#(nonnull UIView *)#> duration:<#(NSTimeInterval)#> options:<#(UIViewAnimationOptions)#> completion:<#^(BOOL finished)completion#>]
  • 單個(gè)視圖的過渡效果 [UIView transitionWithView:<#(nonnull UIView *)#> duration:<#(NSTimeInterval)#> options:<#(UIViewAnimationOptions)#> animations:<#^(void)animations#> completion:<#^(BOOL finished)completion#>]

UIView動(dòng)畫可以設(shè)置的動(dòng)畫屬性有
  • 1、大小變化(frame)
  • 2、拉伸變化(bounds)
  • 3、中心位置變化(center)
  • 4、旋轉(zhuǎn)(transform)
  • 5、透明度(aipha)
  • 6、背景色(backgroundColor)

transform屬性作用:給我們的控件做一些形變,(平移,縮放,旋轉(zhuǎn))
移動(dòng)

// 平移
//每次移動(dòng)都是相對(duì)于上次位置
 _redView.transform = CGAffineTransformTranslate(_redView.transform, 100, 0);
//每次移動(dòng)都是相對(duì)于最開始的位置
 _redView.transform = CGAffineTransformMakeTranslation(200, 0);

縮放

// sx:寬度縮放的比例 sy:高度縮放的比例
//每次縮放都是相對(duì)于最初的大小
_redView.transform = CGAffineTransformMakeScale(0.5, 0.5);
//每次縮放都是相對(duì)于上次的大小
_redView.transform = CGAffineTransformScale(_redView.transform, 0.5, 0.5);

旋轉(zhuǎn)

// 每次旋轉(zhuǎn)都是相對(duì)于最初的角度
_redView.transform = CGAffineTransformMakeRotation(M_PI_4);
//每次旋轉(zhuǎn)都是相對(duì)于現(xiàn)在的角度
_redView.transform = CGAffineTransformRotate(_redView.transform, M_PI_4);

實(shí)戰(zhàn)說明

1、最簡潔的Block動(dòng)畫:包含時(shí)間和動(dòng)畫

代碼

[UIView animateWithDuration:3 animations:^{
        //執(zhí)行動(dòng)畫
        _MyView.transform = CGAffineTransformScale(_MyView.transform, 0.5, 0.5);//縮放
        _MyView.transform = CGAffineTransformRotate(_MyView.transform, M_PI_4);//旋轉(zhuǎn)
        _MyView.transform = CGAffineTransformTranslate(_MyView.transform, 200, 100);//平移
    }];

效果圖

animation1.gif
2、可設(shè)置延遲時(shí)間和過渡效果的Block動(dòng)畫

代碼

[UIView animateWithDuration:3 delay:1 options:UIViewAnimationOptionTransitionCurlDown animations:^{
        //執(zhí)行動(dòng)畫
        _MyView.transform = CGAffineTransformScale(_MyView.transform, 0.5, 0.5);//縮放
        _MyView.transform = CGAffineTransformRotate(_MyView.transform, M_PI_4);//旋轉(zhuǎn)
        _MyView.transform = CGAffineTransformTranslate(_MyView.transform, 200, 100);//平移
        
    } completion:^(BOOL finished) {
        NSLog(@"動(dòng)畫完成的回調(diào)");
    }];

UIViewAnimationOptions的枚舉值如下,可組合使用

UIViewAnimationOptionLayoutSubviews//進(jìn)行動(dòng)畫時(shí)布局子控件
UIViewAnimationOptionAllowUserInteraction//進(jìn)行動(dòng)畫時(shí)允許用戶交互
UIViewAnimationOptionBeginFromCurrentState//從當(dāng)前狀態(tài)開始動(dòng)畫
UIViewAnimationOptionRepeat//無限重復(fù)執(zhí)行動(dòng)畫
UIViewAnimationOptionAutoreverse//執(zhí)行動(dòng)畫回路
UIViewAnimationOptionOverrideInheritedDuration//忽略嵌套動(dòng)畫的執(zhí)行時(shí)間設(shè)置
UIViewAnimationOptionOverrideInheritedCurve//忽略嵌套動(dòng)畫的曲線設(shè)置
UIViewAnimationOptionAllowAnimatedContent//轉(zhuǎn)場(chǎng):進(jìn)行動(dòng)畫時(shí)重繪視圖
UIViewAnimationOptionShowHideTransitionViews//轉(zhuǎn)場(chǎng):移除(添加和移除圖層的)動(dòng)畫效果
UIViewAnimationOptionOverrideInheritedOptions//不繼承父動(dòng)畫設(shè)置
UIViewAnimationOptionCurveEaseInOut//時(shí)間曲線,慢進(jìn)慢出(默認(rèn)值)
UIViewAnimationOptionCurveEaseIn//時(shí)間曲線,慢進(jìn)
UIViewAnimationOptionCurveEaseOut//時(shí)間曲線,慢出
UIViewAnimationOptionCurveLinear//時(shí)間曲線,勻速
UIViewAnimationOptionTransitionNone//轉(zhuǎn)場(chǎng),不使用動(dòng)畫
UIViewAnimationOptionTransitionFlipFromLeft//轉(zhuǎn)場(chǎng),從左向右旋轉(zhuǎn)翻頁
UIViewAnimationOptionTransitionFlipFromRight//轉(zhuǎn)場(chǎng),從右向左旋轉(zhuǎn)翻頁
UIViewAnimationOptionTransitionCurlUp//轉(zhuǎn)場(chǎng),下往上卷曲翻頁
UIViewAnimationOptionTransitionCurlDown//轉(zhuǎn)場(chǎng),從上往下卷曲翻頁
UIViewAnimationOptionTransitionCrossDissolve//轉(zhuǎn)場(chǎng),交叉消失和出現(xiàn)
UIViewAnimationOptionTransitionFlipFromTop//轉(zhuǎn)場(chǎng),從上向下旋轉(zhuǎn)翻頁
UIViewAnimationOptionTransitionFlipFromBottom//轉(zhuǎn)場(chǎng),從下向上旋轉(zhuǎn)翻頁

3、Spring動(dòng)畫

usingSpringWithDamping:震動(dòng)效果,范圍0~1,數(shù)值越小震動(dòng)效果越明顯
initialSpringVelocity:初始速度,數(shù)值越大初始速度越快

 [UIView animateWithDuration:3 delay:0 usingSpringWithDamping:0.1 initialSpringVelocity:100 options:UIViewAnimationOptionRepeat animations:^{
        //執(zhí)行動(dòng)畫
        _MyView.transform = CGAffineTransformScale(_MyView.transform, 0.5, 0.5);//縮放
        _MyView.transform = CGAffineTransformRotate(_MyView.transform, M_PI_4);//旋轉(zhuǎn)
        _MyView.transform = CGAffineTransformTranslate(_MyView.transform, 200, 100);//平移

    } completion:^(BOOL finished) {
        
    }];

效果圖

animation2.gif
4、Keyframes動(dòng)畫

iOS7.0后新增關(guān)鍵幀動(dòng)畫,支持屬性關(guān)鍵幀,不支持路徑關(guān)鍵幀
options:動(dòng)畫的過渡效果

[UIView animateKeyframesWithDuration:0.5 delay:0 options:UIViewKeyframeAnimationOptionCalculationModeCubicPaced animations:^{
        _MyView.backgroundColor = [UIColor blueColor];
    } completion:nil];
    
    [UIView animateKeyframesWithDuration:1 delay:0 options:UIViewKeyframeAnimationOptionCalculationModeCubicPaced animations:^{
        _MyView.backgroundColor = [UIColor grayColor];
    } completion:nil];
    
    [UIView animateKeyframesWithDuration:1.5 delay:0 options:UIViewKeyframeAnimationOptionCalculationModeCubicPaced animations:^{
        _MyView.backgroundColor = [UIColor greenColor];
    } completion:nil];
    
    [UIView animateKeyframesWithDuration:2 delay:0 options:UIViewKeyframeAnimationOptionCalculationModeCubicPaced animations:^{
        _MyView.backgroundColor = [UIColor redColor];
    } completion:nil];

UIViewKeyframeAnimationOptions的枚舉值如下,可組合使用:

UIViewAnimationOptionLayoutSubviews//進(jìn)行動(dòng)畫時(shí)布局子控件
UIViewAnimationOptionAllowUserInteraction//進(jìn)行動(dòng)畫時(shí)允許用戶交互
UIViewAnimationOptionBeginFromCurrentState//從當(dāng)前狀態(tài)開始動(dòng)畫
UIViewAnimationOptionRepeat//無限重復(fù)執(zhí)行動(dòng)畫
UIViewAnimationOptionAutoreverse//執(zhí)行動(dòng)畫回路
UIViewAnimationOptionOverrideInheritedDuration//忽略嵌套動(dòng)畫的執(zhí)行時(shí)間設(shè)置
UIViewAnimationOptionOverrideInheritedOptions//不繼承父動(dòng)畫設(shè)置
UIViewKeyframeAnimationOptionCalculationModeLinear//運(yùn)算模式:連續(xù)
UIViewKeyframeAnimationOptionCalculationModeDiscrete//運(yùn)算模式:離散
UIViewKeyframeAnimationOptionCalculationModePaced//運(yùn)算模式:均勻執(zhí)行
UIViewKeyframeAnimationOptionCalculationModeCubic//運(yùn)算模式:平滑
UIViewKeyframeAnimationOptionCalculationModeCubicPaced//運(yùn)算模式:平滑均勻

效果圖

animation3.gif
5、轉(zhuǎn)場(chǎng)動(dòng)畫
單個(gè)視圖的過渡效果

代碼

[UIView transitionWithView:_MyView duration:1 options:UIViewAnimationOptionOverrideInheritedCurve animations:^{
        _MyView.backgroundColor = [UIColor greenColor];
    } completion:nil];

效果圖

animation4.gif
從舊視圖轉(zhuǎn)到新視圖的動(dòng)畫效果
[UIView transitionFromView:_MyView toView:_view duration:1 options:UIViewAnimationOptionTransitionFlipFromTop completion:nil];

CAAnimation核心動(dòng)畫

在iOS的不同圖形層次中都可以寫動(dòng)畫代碼。越上層,封裝程度越高,動(dòng)畫實(shí)現(xiàn)越簡潔越簡單,但是自由度越低;反之亦然。
如果想要做出更炫的動(dòng)畫,就必須要了解CAAnimation核心動(dòng)畫了。

Core Animation結(jié)構(gòu)
1053533-6eae72f7fd9bd271.png
屏幕快照 2017-04-20 下午9.56.37.png

基礎(chǔ)動(dòng)畫(CABasicAnimation)

基礎(chǔ)動(dòng)畫(CABasicAnimation),通過設(shè)定起始點(diǎn),終點(diǎn),時(shí)間,動(dòng)畫會(huì)沿著你這設(shè)定點(diǎn)進(jìn)行移動(dòng)。可以看做特殊的CAKeyFrameAnimation

開始之前我們需要先了解一個(gè)概念:CALayer

CALayer是個(gè)與UIView很類似的概念,同樣有backgroundColor、frame等相似的屬性,我們可以將UIView看做一種特殊的CALayer。但實(shí)際上UIView是對(duì)CALayer封裝,在CALayer的基礎(chǔ)上再添加交互功能。UIView的顯示必須依賴于CALayer。
我們同樣可以跟新建view一樣新建一個(gè)layer,然后添加到某個(gè)已有的layer上,同樣可以對(duì)layer調(diào)整大小、位置、透明度等。
一般來說,layer可以有兩種用途:一是對(duì)view相關(guān)屬性的設(shè)置,包括圓角、陰影、邊框等參數(shù),更詳細(xì)的參數(shù)請(qǐng)點(diǎn)擊這里;二是實(shí)現(xiàn)對(duì)view的動(dòng)畫操控。因此對(duì)一個(gè)view進(jìn)行動(dòng)畫,本質(zhì)上是對(duì)該view的.layer進(jìn)行動(dòng)畫操縱。

注意點(diǎn)1:KeyPath中key值的設(shè)置

實(shí)例化方法

 //圍繞y軸旋轉(zhuǎn)
CABasicAnimation *transformAnima = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];

使用方法animationWithKeyPath:對(duì)CABasicAnimation進(jìn)行實(shí)例化,并指定Layer的屬性作為關(guān)鍵路徑進(jìn)行注冊(cè)。
keyPath決定了基礎(chǔ)動(dòng)畫的類型,該值不能隨便取,一旦取錯(cuò)就達(dá)不到想要的效果。要改變位置就取position,要改變透明度就取opacity,要等比例縮放就取transform.scale...
一些常用的animationWithKeyPath值的總結(jié)

3D62A8E2-94E2-4FC3-AE05-A71296F4B324.png
注意點(diǎn)2:fillMode屬性的理解

該屬性定義了你的動(dòng)畫在開始和結(jié)束時(shí)的動(dòng)作。默認(rèn)值是 kCAFillModeRemoved
fillMode的作用就是決定當(dāng)前對(duì)象過了非active時(shí)間段的行為. 非active時(shí)間段是指動(dòng)畫開始之前以及動(dòng)畫結(jié)束之后。如果是一個(gè)動(dòng)畫CAAnimation,則需要將其removedOnCompletion設(shè)置為NO,要不然fillMode不起作用.

kCAFillModeRemoved 這個(gè)是默認(rèn)值,也就是說當(dāng)動(dòng)畫開始前和動(dòng)畫結(jié)束后,動(dòng)畫對(duì)layer都沒有影響,動(dòng)畫結(jié)束后,layer會(huì)恢復(fù)到之前的狀態(tài)
kCAFillModeForwards 當(dāng)動(dòng)畫結(jié)束后,layer會(huì)一直保持著動(dòng)畫最后的狀態(tài)
kCAFillModeBackwards這個(gè)和kCAFillModeForwards是相對(duì)的,就是在動(dòng)畫開始前,你只要將動(dòng)畫加入了一個(gè)layer,layer便立即進(jìn)入動(dòng)畫的初始狀態(tài)。因?yàn)橛锌赡艹霈F(xiàn)fromValue不是目前l(fā)ayer的初始狀態(tài)的情況,如果fromValue就是layer當(dāng)前的狀態(tài),則這個(gè)參數(shù)就沒太大意義。
kCAFillModeBoth理解了上面兩個(gè),這個(gè)就很好理解了,這個(gè)其實(shí)就是上面兩個(gè)的合成.動(dòng)畫加入后開始之前,layer便處于動(dòng)畫初始狀態(tài),動(dòng)畫結(jié)束后layer保持動(dòng)畫最后的狀態(tài).

注意點(diǎn)3

[self.view.layer addAnimation:positionAnima forKey:@"AnimationMoveY"];我們可以根據(jù)這個(gè)Key找到這個(gè)layer

注意點(diǎn)4:一些常用的屬性
7E7672C6-9B0E-4743-9533-C3B506329F1D.png
我們做一個(gè)心跳的效果

代碼

//初始化CALayer
    CALayer *layer = [[CALayer alloc]init];
    layer.backgroundColor = [UIColor redColor].CGColor;
    layer.frame = CGRectMake(100, 100, 100, 100);
    layer.cornerRadius = 10;
    [self.view.layer addSublayer:layer];
    //配置CABasicAnimation
    CABasicAnimation *basicAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    basicAnimation.fromValue = [NSNumber numberWithFloat:1.0];
    basicAnimation.toValue = [NSNumber numberWithFloat:1.5];
    //當(dāng)動(dòng)畫執(zhí)行到toValue指定的狀態(tài)時(shí)是從toValue的狀態(tài)逆回去,還是直接跳到fromValue的狀態(tài)再執(zhí)行一遍
    basicAnimation.autoreverses = YES;
    basicAnimation.removedOnCompletion = NO;
    basicAnimation.duration = 0.5;
    basicAnimation.repeatCount = MAXFLOAT;
    //把動(dòng)畫內(nèi)容添加到layer上
    [layer addAnimation:basicAnimation forKey:@"basicAnimation"];
basicAnimation.gif

關(guān)鍵幀動(dòng)畫(CAKeyFrameAnimation)

CABasicAnimation只能從一個(gè)數(shù)值(fromValue)變到另一個(gè)數(shù)值(toValue),而CAKeyframeAnimation會(huì)使用一個(gè)NSArray保存這些數(shù)值

屬性介紹

  • values:就是上述的NSArray對(duì)象。里面的元素稱為”關(guān)鍵幀”(keyframe)。動(dòng)畫對(duì)象會(huì)在指定的時(shí)間(duration)內(nèi),依次顯示values數(shù)組中的每一個(gè)關(guān)鍵幀

  • path:可以設(shè)置一個(gè)CGPathRef\CGMutablePathRef,讓層跟著路徑移動(dòng)。path只對(duì)CALayer的anchorPoint和position起作用。如果你設(shè)置了path,那么values將被忽略

  • keyTimes:可以為對(duì)應(yīng)的關(guān)鍵幀指定對(duì)應(yīng)的時(shí)間點(diǎn),其取值范圍為0到1.0,keyTimes中的每一個(gè)時(shí)間值都對(duì)應(yīng)values中的每一幀.當(dāng)keyTimes沒有設(shè)置的時(shí)候,各個(gè)關(guān)鍵幀的時(shí)間是平分的

value方式代碼

 //創(chuàng)建動(dòng)畫對(duì)象
    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    
    //設(shè)置value
    NSValue *value1=[NSValue valueWithCGPoint:CGPointMake(100, 100)];
    NSValue *value2=[NSValue valueWithCGPoint:CGPointMake(200, 100)];
    NSValue *value3=[NSValue valueWithCGPoint:CGPointMake(200, 200)];
    NSValue *value4=[NSValue valueWithCGPoint:CGPointMake(100, 200)];
    NSValue *value5=[NSValue valueWithCGPoint:CGPointMake(100, 300)];
    NSValue *value6=[NSValue valueWithCGPoint:CGPointMake(200, 400)];
    
    
    animation.values=@[value1,value2,value3,value4,value5,value6];
    
    //重復(fù)次數(shù) 默認(rèn)為1
    animation.repeatCount=MAXFLOAT;
    //設(shè)置是否原路返回默認(rèn)為不
    animation.autoreverses = YES;
    //設(shè)置移動(dòng)速度,越小越快
    animation.duration = 4.0f;
    animation.removedOnCompletion = NO;
    animation.fillMode = kCAFillModeForwards;
    
    //給這個(gè)view加上動(dòng)畫效果
    [_keyFrameView.layer addAnimation:animation forKey:nil];
    
KeyFrameValue.gif

path方法代碼

CAKeyframeAnimation *anima = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(100, 100)];
    [path addLineToPoint:CGPointMake(150, 150)];
    [path addLineToPoint:CGPointMake(100, 200)];
    [path addLineToPoint:CGPointMake(50, 150)];

    anima.path = path.CGPath;
    anima.duration = 2.0f;
    anima.repeatCount= MAXFLOAT;
    anima.autoreverses = NO;
    anima.removedOnCompletion = NO;
    anima.fillMode = kCAFillModeForwards;
    
    
    [_keyFrameView.layer addAnimation:anima forKey:@"pathAnimation"];
KeyFramePath.gif

動(dòng)畫組動(dòng)畫(CAAnimationGroup)

動(dòng)畫組(CAAnimationGroup)是核心動(dòng)畫中又一個(gè)比較重要的知識(shí)點(diǎn)。動(dòng)畫組顧名思義就是一組動(dòng)畫,它可以將多個(gè)動(dòng)畫對(duì)象保存起來,然后再將其添加到layer上,讓組中所有的動(dòng)畫對(duì)象同時(shí)并發(fā)執(zhí)行。

 /****************** 創(chuàng)建平移動(dòng)畫 ******************/
    CABasicAnimation *basicAnim = [CABasicAnimation animation];
    // 設(shè)置動(dòng)畫屬性
    basicAnim.keyPath = @"position.y";
    basicAnim.toValue = @350;
    
    /****************** 創(chuàng)建縮放動(dòng)畫 ******************/
    CABasicAnimation *scaleAnim = [CABasicAnimation animation];
    // 設(shè)置動(dòng)畫屬性
    scaleAnim.keyPath = @"transform.scale";
    scaleAnim.toValue = @0.5;
    
   ;
    
    /****************** 創(chuàng)建動(dòng)畫組 ******************/
    CAAnimationGroup *groupAnim = [CAAnimationGroup animation];
    // 將動(dòng)畫對(duì)象都添加到CAAnimationGroup對(duì)象中
    groupAnim.animations = @[basicAnim, scaleAnim];
    
    /****************** 通過動(dòng)畫組對(duì)象統(tǒng)一設(shè)置動(dòng)畫屬性和狀態(tài) ******************/
    // 設(shè)置動(dòng)畫的執(zhí)行時(shí)長
    groupAnim.duration = 0.5;
    // 動(dòng)畫完成時(shí)保持在最新的狀態(tài)
    groupAnim.removedOnCompletion = NO;
    groupAnim.fillMode = kCAFillModeForwards;
    
    
    groupAnim.duration = 2.0f;
    groupAnim.repeatCount= MAXFLOAT;
    groupAnim.autoreverses = YES;
    groupAnim.removedOnCompletion = NO;
    groupAnim.fillMode = kCAFillModeForwards;

    /****************** 將動(dòng)畫組對(duì)象添加到redView的layer上 ******************/
    [_animationGroupView.layer addAnimation:groupAnim forKey:nil];

animationGroup.gif

轉(zhuǎn)場(chǎng)動(dòng)畫(CATranstion)

CATransition是CAAnimation的子類,用于做轉(zhuǎn)場(chǎng)動(dòng)畫,能夠?yàn)閷犹峁┮瞥銎聊缓鸵迫肫聊坏膭?dòng)畫效果。iOS比Mac OS X的轉(zhuǎn)場(chǎng)動(dòng)畫效果少一點(diǎn)
UINavigationController就是通過CATransition實(shí)現(xiàn)了將控制器的視圖推入屏幕的動(dòng)畫效果
動(dòng)畫屬性:
type:動(dòng)畫過渡類型
subtype:動(dòng)畫過渡方向
startProgress:動(dòng)畫起點(diǎn)(在整體動(dòng)畫的百分比)
endProgress:動(dòng)畫終點(diǎn)(在整體動(dòng)畫的百分比)

轉(zhuǎn)場(chǎng)動(dòng)畫過渡效果
屏幕快照 2016-05-25 20.41.32.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 228,646評(píng)論 6 533
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 98,595評(píng)論 3 418
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事?!?“怎么了?”我有些...
    開封第一講書人閱讀 176,560評(píng)論 0 376
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,035評(píng)論 1 314
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 71,814評(píng)論 6 410
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 55,224評(píng)論 1 324
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼。 笑死,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,301評(píng)論 3 442
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 42,444評(píng)論 0 288
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 48,988評(píng)論 1 335
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 40,804評(píng)論 3 355
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 42,998評(píng)論 1 370
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,544評(píng)論 5 360
  • 正文 年R本政府宣布,位于F島的核電站,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 44,237評(píng)論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,665評(píng)論 0 26
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,927評(píng)論 1 287
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 51,706評(píng)論 3 393
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 47,993評(píng)論 2 374

推薦閱讀更多精彩內(nèi)容

  • 在iOS中隨處都可以看到絢麗的動(dòng)畫效果,實(shí)現(xiàn)這些動(dòng)畫的過程并不復(fù)雜,今天將帶大家一窺ios動(dòng)畫全貌。在這里你可以看...
    每天刷兩次牙閱讀 8,543評(píng)論 6 30
  • 在iOS實(shí)際開發(fā)中常用的動(dòng)畫無非是以下四種:UIView動(dòng)畫,核心動(dòng)畫,幀動(dòng)畫,自定義轉(zhuǎn)場(chǎng)動(dòng)畫。 1.UIView...
    請(qǐng)叫我周小帥閱讀 3,128評(píng)論 1 23
  • 在iOS中隨處都可以看到絢麗的動(dòng)畫效果,實(shí)現(xiàn)這些動(dòng)畫的過程并不復(fù)雜,今天將帶大家一窺iOS動(dòng)畫全貌。在這里你可以看...
    F麥子閱讀 5,131評(píng)論 5 13
  • 粉骨碎身全不怕, 要留清白在人間!<小拳石> 基礎(chǔ)知識(shí):iOS能夠?qū)崿F(xiàn)動(dòng)畫的方式:(如上圖) UIView基礎(chǔ)實(shí)現(xiàn)...
    云之君兮鵬閱讀 4,696評(píng)論 11 53
  • 先看看CAAnimation動(dòng)畫的繼承結(jié)構(gòu) CAAnimation{ CAPropertyAnimation { ...
    時(shí)間不會(huì)倒著走閱讀 1,674評(píng)論 0 1