Re: wits end with nsview and nsrectfill()
Re: wits end with nsview and nsrectfill()
- Subject: Re: wits end with nsview and nsrectfill()
- From: Steve Christensen <email@hidden>
- Date: Sun, 30 Nov 2014 09:43:36 -0800
Why aren't you creating the subview in -initWithFrame: or in a nib/storyboard? The purpose of -drawRect: is solely to [re-]draw the contents of one view, not build a view hierarchy. I expect that modifying the view hierarchy while in the middle of a drawing cycle is leaving views in an inconsistent state.
> On Nov 30, 2014, at 9:30 AM, Navneet Kumar <email@hidden> wrote:
>
> I have a custom view in which I am setting the background using NSRectFill() in drawRect:. I am also adding a text field as subview in this method. The textfield is non-selectable, non-editable and is not set to draw background.
>
> When the view comes to front, the background is same, but when it refreshes, the area apart from the text field becomes a bit darker and the text field area shows the original background, this creates a contrast which I want to get rid of.
>
> The view is set to return YES to isOpaque.
>
> I have tried a lot of things but to no avail.
> I have tried CGContext approach to fill rect.
> I also tried setting the color before NSRectFill() to a opaque color as well.
>
> The problem is gone if I removeFromSuperview and create the custom view again and again on each drawRect: of the super view. But this consumes a lot of CPU.
>
> An image showing the contrast is attached herewith.
>
> Please help.
>
> Best,
> Navneet
_______________________________________________
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