Ausgabe
Ist es möglich, einen Teil davon zu entfernen NSBezierPath
, der durch eine NSRect
Region innerhalb des Pfads definiert ist?
Lösung
Unbedingt. Dies ist, was Clipping-Bereiche tun:
// Save the current clipping region
[NSGraphicsContext saveGraphicsState];
NSRect dontDrawThisRect = NSMakeRect(x, y, w, h);
// Either:
NSRectClip(dontDrawThisRect);
// Or (usually for more complex shapes):
//[[NSBezierPath bezierPathWithRect:dontDrawThisRect] addClip];
[myBezierPath fill]; // or stroke, or whatever you do
// Restore the clipping region for further drawing
[NSGraphicsContext restoreGraphicsState];
Beantwortet von – jscs
Antwort geprüft von – Willingham (FixError Volunteer)