On Tue, May 5, 2009 at 2:57 PM, McLaughlin, Michael P. <[email protected]> wrote: > Naturally, I came up with a solution two minutes after posting my query to > this list :-( > > My solution is > > [[NSBezierPath bezierPathWithRect:rect] setClip]; > > where rect is the viewRect. This works for me. It might not be the best > solution in all cases.
It's not the best solution in any case. The documentation says: "You should avoid using this method as a way of adjusting the clipping path, as it may expand the clipping path beyond the bounds set by the enclosing view." This is somewhat misleading, because it's more dangerous than this lets on. For example, the system could be drawing only a part of your view, and this code could expand the clipping rect beyond that region. This can then result in drawing artifacts if your view is not completely opaque. The proper way to deal with this and with any other irreversible change to the graphics context is to save the context state before you make the change, and then restore it when you're done. See the NSGraphicsContext class. Mike _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
