Re: wits end with nsview and nsrectfill()
Re: wits end with nsview and nsrectfill()
- Subject: Re: wits end with nsview and nsrectfill()
- From: Kyle Sluder <email@hidden>
- Date: Sun, 30 Nov 2014 09:54:00 -0800
On Nov 30, 2014, at 9:30 AM, Navneet Kumar <email@hidden> wrote:
>
> Hi,
>
> I have a custom view in which I am setting the background using NSRectFill() in drawRect:.
You’re aware that this function is only really suitable for drawing opaque colors, yes? If you NSRectFill() with a transparent color, it will not blend that color with the existing backing store. Instead, it will replace all pixels in that rect with transparent ones, obliterating any drawing performed by ancestor views in the hierarchy.
> I am also adding a text field as subview in this method.
This is not allowed. -drawRect: is for drawing, not mutating your view hierarchy.
If you want to position/install views at the last possible second before the drawing pass, use -viewWillDraw. But you have not offered any reasons why you need to dynamically add or remove views at all, much less in tandem with the drawing pass.
--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