我需要将UIView沿着bezier路径从一个点拖到另一个点,最好的方法是什么?
答案 0 :(得分:2)
这是将uiview从一个点拖动到另一个点的最简单方法。
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:startingPoint];
[path addLineToPoint:endPoint]; //you can use addCurveToPoint: , addArcToPoint:, etc
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.duration = 10.0;
pathAnimation.path = path;
pathAnimation.removeOnCompletion = NO ;
[myView.layer addAnimation:pathAnimation forKey:@"pathAnimation"];