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

你可能感兴趣的:(iOS 抛物线关键帧动画 图片无限旋转)