iOS 抛物线关键帧动画 图片无限旋转

// 抛物线关键帧动画

-(void)rrr
{
    CAKeyframeAnimation *keyframeAnimation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
    CGMutablePathRef path = CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL, self.imageView.layer.position.x, self.imageView.layer.position.y);//移动到起始点
    CGPoint endPosition = CGPointMake(50, 50);
    CGPathAddQuadCurveToPoint(path, NULL, 100, 100, endPosition.x, endPosition.y);
    CGPathAddQuadCurveToPoint(path, NULL, 200, 200, endPosition.x, endPosition.y);
    CGPathAddQuadCurveToPoint(path, NULL, 300, 300, endPosition.x, endPosition.y);

    keyframeAnimation.path = path;
    keyframeAnimation.delegate = self;
    CGPathRelease(path);
    keyframeAnimation.duration = 1;
    [self.imageView.layer addAnimation:keyframeAnimation forKey:@"KCKeyframeAnimation_Position"];
}

//图片无限旋转

- (void)startAnimation
{
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];///.y的话就向下移动。
//    animation.fromValue = [NSNumber numberWithFloat:0];
    animation.toValue = [NSNumber numberWithFloat:M_PI *2];
    animation.duration = 0.3;
    animation.removedOnCompletion = NO;//yes的话,又返回原位置了。
    animation.repeatCount = MAXFLOAT;
    animation.fillMode = kCAFillModeForwards;
    [self.imageView.layer addAnimation:animation forKey:@"animateTransform"];
    
}

end

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容