Re: wantsDefaultClipping set to NO
Re: wantsDefaultClipping set to NO
- Subject: Re: wantsDefaultClipping set to NO
- From: Kyle Sluder <email@hidden>
- Date: Thu, 05 Dec 2013 16:12:16 -0800
On Thu, Dec 5, 2013, at 01:03 PM, Leonardo wrote:
> I have to draw a NSShadow out of my NSViews' bounds.
> So I overrided the wantsDefaultClipping methond returning NO.
You can't do this. Drawing outside of your view's bounds isn't
supported. (More specifically, you must not draw outside of the rects
returned by -getRectsBeingDrawn:count:).
If your view ever becomes layer-backed (which is not a state you can
entirely control), it won't necessarily be drawing to a backing store
larger than its bounds.
> A) What's the purpose of the wantsDefaultClipping method?
As per the View Programming Guide[1], it exists to avoid duplicating any
work you're already doing in order to restrict your drawing within the
valid drawable regions.
[1]
<https://developer.apple.com/library/mac/documentation/cocoa/conceptual/CocoaViewsGuide/Optimizing/Optimizing.html>
> C) Or should I simply enlarge the view to draw the shadow? If so, I have
This is the correct approach.
> to
> change the origin and size of the view. Therefore, how can I adjust the
> origin and size that the user enters on UI with the bound values I use in
> the setFrameOrigin and setFrameSize ?
You don't. Stop using -setFrame{,Origin,Size}: directly and start using
auto layout. You can override -alignmentRectInsets to return the amount
of padding on each side of your view, giving you enough room to draw
your shadow.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden