animationBezier曲线的一个点

是可以animation一个贝塞尔曲线的一个点? 我正在尝试从一条线向一个箭头平滑过渡。

动画Bezier点

这是代码中的行

//// Color Declarations UIColor* white = [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 0.374]; //// Group { //// Bezier Drawing UIBezierPath* bezierPath = [UIBezierPath bezierPath]; [bezierPath moveToPoint: CGPointMake(30.5, 43.5)]; [bezierPath addLineToPoint: CGPointMake(30.5, 29.59)]; [bezierPath addLineToPoint: CGPointMake(30.5, 15.5)]; bezierPath.lineCapStyle = kCGLineCapRound; bezierPath.lineJoinStyle = kCGLineJoinBevel; [white setStroke]; bezierPath.lineWidth = 5.5; [bezierPath stroke]; } 

…但是我不知道如何select一个点,并制作animation。 这甚至有可能吗?

使用CAShapeLayer显式CGPathanimation:

 // Create the starting path. Your curved line. UIBezierPath * startPath; // Create the end path. Your straight line. UIBezierPath * endPath; // Create the shape layer to display and animate the line. CAShapeLayer * myLineShapeLayer = [[CAShapeLayer alloc] init]; CABasicAnimation * pathAnimation = [CABasicAnimation animationWithKeyPath:@"path"]; pathAnimation.fromValue = (__bridge id)[startPath CGPath]; pathAnimation.toValue = (__bridge id)[endPath CGPath]; pathAnimation.duration = 5.0f; [myLineShapeLayer addAnimation:pathAnimation forKey:@"animationKey"]; 

目前还不清楚你在问什么。 你是否试图通过移动其中一个控制点来改变线条的形状?

animation改变path的方法是创build一个CAShapeLayer并将其安装为视图图层的子图层。 然后,如果更改与形状图层关联的path,系统将使用隐式animation进行更改。

请注意,形状图层中的path需要具有相同数量/types的控制点,或者animation的结果是“未定义的”。