获取 UIBezierPath Stroke 的轮廓路径

Get UIBezierPath Stroke's Outline Path

我有一个 UIBezierPath 笔划,现在我想获取笔划的轮廓路径(而不是笔划的路径本身),有什么办法可以得到吗?或者至少 NSLog UIBezierPath 笔划的轮廓路径?谢谢

您可以使用 CGPathCreateCopyByStrokingPath 来实现。

UIBezierPath *path = ...;
CGFloat lineWidth = 10;
CGPathRef cgStrokedPath = CGPathCreateCopyByStrokingPath(path.CGPath, NULL,
    lineWidth, kCGLineCapRound, kCGLineJoinRound, 0);
UIBezierPath *strokedPath = [UIBezierPath bezierPathWithCGPath:cgStrokedPath];