Sto creando una forma complessa utilizzando alcuni CGRects ed Ellips. Mi piacerebbe accarezzare quel percorso una volta che è stato creato. Quando accarezzo il percorso, tocca ogni forma. C'è un modo per unire ogni forma in un unico percorso, quindi il tratto non si interseca?Unisci più CGPath insieme per creare un percorso
int thirds = self.height/3;
CGPathRef aPath = CGPathCreateMutable();
CGRect rectangle = CGRectMake((58 - 10)/2, 46, 10, self.height - 58);
CGPathAddRect(aPath, nil, rectangle);
CGPathAddEllipseInRect(aPath, nil, CGRectMake((58 - 48)/2, 0, 48, 48));
CGPathAddEllipseInRect(aPath, nil, CGRectMake((58 - 48)/2, thirds, 48, 48));
CGPathAddEllipseInRect(aPath, nil, CGRectMake((58 - 48)/2, thirds * 2, 48, 48));
CGPathAddEllipseInRect(aPath, nil, CGRectMake(0, self.height - 58, 58, 58));
CGPathCloseSubpath(aPath);
CGPathRef other = CGPathCreateCopy(aPath);
CAShapeLayer *square = [CAShapeLayer layer];
square.fillColor = [UIColor colorWithRed:36/255.0f green:56/255.0f blue:82/255.0f alpha:1.0f].CGColor;
square.strokeColor = [UIColor colorWithRed:50/255.0f green:70/255.0f blue:96/255.0f alpha:1.0f].CGColor;
square.path = other;
[self.layer addSublayer:square];
UPDATE
Ho provato con l'aggiunta di percorsi insieme ed ho ottenuto esattamente lo stesso risultato
CGPathAddPath(aPath, nil, CGPathCreateWithRect(rectangle, nil));
CGPathAddPath(aPath, nil, CGPathCreateWithEllipseInRect(CGRectMake((58 - 48)/2, 0, 48, 48), nil));
CGPathAddPath(aPath, nil, CGPathCreateWithEllipseInRect(CGRectMake((58 - 48)/2, thirds, 48, 48), nil));
CGPathAddPath(aPath, nil, CGPathCreateWithEllipseInRect(CGRectMake((58 - 48)/2, thirds * 2, 48, 48), nil));
CGPathAddPath(aPath, nil, CGPathCreateWithEllipseInRect(CGRectMake(0, self.height - 58, 58, 58), nil));
'CGPathAddPath (path1, NULL, path2)' – CodaFi
@CodaFi Quindi creare un nuovo percorso per ogni forma e usare 'CGPathAddPath'? – brenjt