CAKeyframeAnimation *keyframeAnimation=[CAKeyframeAnimation animationWithKeyPath:@"position"];//抛物线运动
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, testView.layer.position.x, testView.layer.position.y);//移动到起始点
CGPathAddQuadCurveToPoint(path, NULL, midPoint.x, midPoint.y, endPoint.x, end.y);
keyframeAnimation.path = path;
keyframeAnimation.delegate = self;
CGPathRelease(path);
keyframeAnimation.duration = 2;
[testView.layer addAnimation:keyframeAnimation forKey:@"KCKeyframeAnimation_Position"];
//旋转运动
CABasicAnimation *basicAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
basicAnimation.duration = 0.2;
basicAnimation.repeatCount = 10;
basicAnimation.removedOnCompletion = NO;
basicAnimation.toValue = @(M_PI);
[testView.layer addAnimation:basicAnimation forKey:@"basic"];
//缩放运动
CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scaleAnimation.duration = 2;
scaleAnimation.toValue = @(0.1);
[testView.layer addAnimation:scaleAnimation forKey:@"scale"];
类似加入购物车的抛物线动画
最新推荐文章于 2019-06-28 21:23:58 发布