iOS版のCAKeyframeAnimationキーフレームアニメーションシニアアニメーション

1ロックアニメーションの実現

CAKeyframeAnimation *アニメーション= [CAKeyframeAnimation animationWithKeyPath:@ "transform.rotation"];

 CGFloat天使= M_PI_4 / 12.0。

 [アニメーションsetValues:@ [@(天使)、@( - 天使)、@(天使)]]。

[Animのsetrepeatcount:HUGE_VALF]。

 【Self.anima.layer addAnimation 6 forKey:なし]。

アニメーションを達成するために2ベジェ曲線

  キーフレームアニメーションの// 1例
    CAKeyframeAnimation Animの* = [CAKeyframeAnimation animationWithKeyPath:@「位置」];
    
    //パス2を設定する
    [アニメーションsetDuration:持続時間];
    
    中間制御点使って画面上の所与//ランダムポイント
    するCGPoint CPを= [自己randomPoint];
    
    CGMutablePathRef CGPathCreateMutableパス=();
    
    //設定出発点
    CGPathMoveToPoint(パス、NULL、self.center.x、self.center.y);
    コントロールポイントベジェ曲線に追加//
    CGPathAddQuadCurveToPoint (パス、NULL、cp.x、cp.y、to.x、to.y);
    
    [AnimのSETPATH:パス];
    CGPathRelease(パス);
    
    // 5)は、アニメーションの最後に設定キー目標位置を記録し、補正位置
    [AnimのsetValueの:@ "translationTo" forKey:@ "animationType"];
    [AnimのsetValueの:[NSValue valueWithCGPoint:forKeyへ]:@ "targetPoint "];
    [AnimのsetDelegate:セルフ];
    
    //は、レイヤ3にアニメーションを追加
    [self.layer addAnimation:アニメーションforKey:nilを ];

公開された368元の記事 ウォン称賛22 ビュー20万+

おすすめ

転載: blog.csdn.net/BianHuanShiZhe/article/details/104972339
おすすめ