1
我的CGPathRef
有5個元素,我想刪除起始點,並有一個4個元素的路徑,其起點與我想要刪除的起點的路徑的末尾相同。與CGPathApplierFunction異常
這是現在我的函數,其產生一個異常:
static void constructPath(void *info, const CGPathElement *element)
{
NSBezierPath *bezierPath = (NSBezierPath *)info;
switch (element->type) {
case kCGPathElementMoveToPoint:
// some kind of skipping using points[0] kCGPathElementMoveToPoint
[bezierPath lineToPoint:element->points[1]]; // line exception in gdb
[bezierPath lineToPoint:element->points[2]];
[bezierPath lineToPoint:element->points[3]];
[bezierPath lineToPoint:element->points[4]];
break;
case kCGPathElementAddLineToPoint:
if ([bezierPath isEmpty]) {
[bezierPath moveToPoint:element->points[0]]; // the new start, how to go to next from here ?
} else {
[bezierPath moveToPoint:element->points[1]];
[bezierPath moveToPoint:element->points[2]];
[bezierPath moveToPoint:element->points[3]];
[bezierPath moveToPoint:element->points[4]];
}
break;
default:
break;
}
}
由於您嘗試在空路徑中添加一行,因此拋出異常。你首先需要移動到原始點。 –