Ios CAKeyframeAnimation动画在没有第一帧(路径)的情况下开始

Ios CAKeyframeAnimation动画在没有第一帧(路径)的情况下开始,ios,objective-c,caanimation,cakeyframeanimation,Ios,Objective C,Caanimation,Cakeyframeanimation,我想用不同的贝塞尔形状制作面具的动画。我的动画开始,但我看不到第一条路径。代码如下: - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. _shapeLayer = [CAShapeLayer layer]; [self drawParentLayer]; } - (void)drawParentLayer { _sh

我想用不同的贝塞尔形状制作面具的动画。我的动画开始,但我看不到第一条路径。代码如下:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    _shapeLayer = [CAShapeLayer layer];
    [self drawParentLayer];
}

- (void)drawParentLayer {
    _shapeLayer.frame = CGRectMake(0, 0, 350, 500);
    _shapeLayer.lineWidth = 3;
    _shapeLayer.strokeColor = [UIColor blackColor].CGColor;
    _shapeLayer.fillColor = UIColor.whiteColor.CGColor;
    _shapeLayer.path = [UIBezierPath bezierPathWithRect:_shapeLayer.bounds].CGPath;
    _shapeLayer.masksToBounds = NO;
    [self.view.layer addSublayer:_shapeLayer];
}
然后我在触摸的位置创建遮罩层。 如何获得接触点:

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView:self.view];

    CGPoint locationInLayer = CGPointMake(location.x - _shapeLayer.frame.origin.x, location.y - _shapeLayer.frame.origin.y);

    _shapeLayer.fillColor = UIColor.yellowColor.CGColor;
    [self createBezierLayerInPoint:locationInLayer];
}
下面是从bezier1到bezier3的图片:

遮罩(bezier)层的动画:

正如我前面提到的,动画从object2开始。所以,也许这只是一个简单的错误,但我看不出来


谢谢大家!

问题是
keyTimes
数组中的第二个值。由于命名器和分母是整数,因此结果为零。您应该强制执行如下浮点除法:

frameA.keyTimes = @[@0.0, @(1.0/3.0), @1.0];

@clements我可以问你一个与现金支付相关但与此问题无关的附加问题吗?@O.Daniel:是的,但我认为最好在这个问题上创建一个单独的问题。@clements是的,我创建了它。
- (void)animate:(CAShapeLayer *)layer {

    CAKeyframeAnimation *frameA = [CAKeyframeAnimation animation];
    [frameA setKeyPath:@"path"];
    frameA.values = @[(id)[BezierObject createBezierObject1].CGPath, (id)[BezierObject createBezierObject2].CGPath, (id)[BezierObject createBezierObject3].CGPath];
    frameA.keyTimes = @[@0, @(1/3), @1];
    frameA.additive = YES;
    frameA.removedOnCompletion = NO;
    frameA.fillMode = kCAFillModeForwards;
    frameA.duration = 3;

    [layer addAnimation:frameA forKey:@"path"];
}
frameA.keyTimes = @[@0.0, @(1.0/3.0), @1.0];