I have a UIBezierPath
stroke, now I want to get the stroke's outline path(not the stroke's path itself), is there a way I could get that? or at least NSLog
the UIBezierPath
stroke's outline path? Thanks
Asked
Active
Viewed 750 times
4

Ronak Chaniyara
- 5,335
- 3
- 24
- 51

jane
- 309
- 2
- 11
1 Answers
7
You can use CGPathCreateCopyByStrokingPath
for this.
UIBezierPath *path = ...;
CGFloat lineWidth = 10;
CGPathRef cgStrokedPath = CGPathCreateCopyByStrokingPath(path.CGPath, NULL,
lineWidth, kCGLineCapRound, kCGLineJoinRound, 0);
UIBezierPath *strokedPath = [UIBezierPath bezierPathWithCGPath:cgStrokedPath];

rob mayoff
- 375,296
- 67
- 796
- 848
-
1Remember to call `CGPathRelease(cgStrokedPath);`! – JimmyB Jan 02 '18 at 10:37