我有一个平移手势识别器来执行一些工作。当手势状态为UIGestureRecognizerStateEnded
时,执行CABasicAnimation
。代码:
CGPathRef path = [self pathToAnimateWithX:0 andY:0];
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];
animation.fromValue = (__bridge id _Nullable)(dragLayer.path);
animation.toValue = (__bridge id)path;
animation.duration = 0.5;
[dragLayer addAnimation:animation forKey:@"dd"];
此代码工作正常。没有问题。但是当我像这样发布path
时:
CGPathRelease(path);
我的应用程序将崩溃,没有崩溃信息。
更新:此处为pathToAnimateWith:
方法
- (CGPathRef)pathToAnimateWithX:(CGFloat)x andY:(CGFloat)y {
UIBezierPath *path = [UIBezierPath bezierPath];
// configure path
[path closePath];
return path.CGPath;
}