如何删除路径的某些部分? 我在屏幕上绘制了一条路径,现在假设我想删除 1/3:
我试过这样做(路径是我的原始路径,cPath是将被剪切的副本):
let sizePath = CGPathGetBoundingBox(path).size
UIGraphicsBeginImageContext(sizePath)
let context = UIGraphicsGetCurrentContext()
let cPath = CGPathCreateMutableCopy(path)
CGContextAddPath(context, cPath)
CGContextDrawPath(context, .Stroke)
let rect = CGRectMake(currentPosition.x, 0, sizePath.width, sizePath.height)
CGContextClipToRect(context, rect)
//How to Recive here this Clipped Path from context???
UIGraphicsEndImageContext()
但我不知道如何从我的上下文中接收这条路径...
最佳答案
您需要CGContextClipToRect
之前您CGContextDrawPath
。裁剪区域只影响后续绘制。
关于ios - 删除部分 CGPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33581397/