隱式動畫、顯式動畫、關鍵幀動畫

作iOS開發有些日子了,知道動畫怎麼去實現,可是:objective-c

  • 什麼是'隱式動畫'?異步

  • 什麼是'顯式動畫'?動畫

  • 什麼是'關鍵幀動畫'?code

一律不知

一、隱式動畫:

  • 核心動畫的隱式動畫模型假定全部動畫圖層屬性的變化應該是漸進的和異步的。動態的動畫場景能夠在沒有顯式的動畫圖層時候實現。改變更畫顯示的圖層的屬性將會致使圖層隱式把舊值動畫顯示爲新值,雖然動畫是持續的,可是設置新的目標值會致使圖層從當前狀態動畫過分到新的目標值對象

OrderSearchVC *search = [[OrderSearchVC alloc] init];
    [self.navigationController pushViewController:search animated:YES];

二、顯式動畫:

  • 核心動畫同事提供了一個顯示動畫模型。該顯式動畫模型須要你建立一個動畫對象,並設置開始值和結束的值,顯示動畫不會開始執行,直到你把該動畫應用到某個圖層上面ci

CABasicAnimation *opAnim = [CABasicAnimation animationWithKeyPath:@opacity];
opAnim.duration = 1.0;
opAnim.fromValue = [NSNumber numberWithFloat:0.1];
opAnim.toValue= [NSNumber numberWithFloat:1.0];
opAnim.repeatCount = 1;
[view.layer addAnimation:opAnim forKey:@animateOpacity];

三、關鍵幀動畫:

CAKeyframeAnimation *opAnim = [CAKeyframeAnimation animationWithKeyPath:@opacity];
opAnim.duration = 6.0;
opAnim.values =[NSArray arrayWithObjects:
                            [NSNumber numberWithFloat:0.0],
                            [NSNumber numberWithFloat:0.1],
                            [NSNumber numberWithFloat:0.3],
                            [NSNumber numberWithFloat:1.0],
                            nil];
opAnim.keyTimes = [ NSArray arrayWithObjects:
                               [NSNumber numberWithFloat:0.0],
                               [NSNumber numberWithFloat:0.3],
                               [NSNumber numberWithFloat:0.6],
                               [NSNumber numberWithFloat:1.0],
                               nil];
[view.layer addAnimation:opAnim forKey:@keyAnimateOpacity];
相關文章
相關標籤/搜索