• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to draw over a control in an NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to draw over a control in an NSView


  • Subject: Re: How to draw over a control in an NSView
  • From: Ken Ferry <email@hidden>
  • Date: Sun, 30 Oct 2011 19:09:30 -0700

On Oct 30, 2011, at 2:06 PM, Jens Alfke <email@hidden> wrote:

>
> On Oct 30, 2011, at 12:46 PM, Alexander Reichstadt wrote:
>
>> given a custom NSView using drawRect to draw, say, a blue rectangle, controls inside that view are always in front of the blue rectangle. Is there a way to draw above controls with drawRect? Also putting a view with controls inside another view that draw in drawRect doesn't change that. Like textfields, they are always above drawn content. How does one draw above controls?
>
> Subviews are always drawn after their superview, so they are visually in front of it. You can’t change that.
> What you can try is adding a subview, positioning it over the control, and putting it in front (I think that means later in the subviews array.) Historically AppKit hasn’t handled overlapping sibling views, but I think that nowadays if you make the parent view layer-backed it will work.

That's actually slightly reversed. AppKit has supported overlapping sibling views since 10.5. Layers complicate the story a bit, because a non-layer backed view can never draw over top of a layer.

-Ken
Cocoa Frameworks

> (But layer-backing views brings its own visual issues, so this may not work out for you.)
>
> Another approach is to subclass the control (or its cell class) and customize its drawing.
>
> —Jens
> _______________________________________________
>
> 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
_______________________________________________

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

  • Follow-Ups:
    • Re: How to draw over a control in an NSView
      • From: Steve Sisak <email@hidden>
References: 
 >How to draw over a control in an NSView (From: Alexander Reichstadt <email@hidden>)
 >Re: How to draw over a control in an NSView (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Sandbox issues
  • Next by Date: Re: How to draw over a control in an NSView
  • Previous by thread: Re: How to draw over a control in an NSView
  • Next by thread: Re: How to draw over a control in an NSView
  • Index(es):
    • Date
    • Thread