• 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: NSView subview backgrounds
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSView subview backgrounds


  • Subject: Re: NSView subview backgrounds
  • From: David Duncan <email@hidden>
  • Date: Mon, 1 Oct 2007 11:06:43 -0700

On Oct 1, 2007, at 10:42 AM, Twisted Theory Software wrote:

I have an NSView subclass, which is getting a gradient background, drawn by NSBezierPaths. I found that even though I'm drawing the background using colours with alpha component equal to 1.0, their colour is being effected by the colour of the object underneath it (which is black). I can check that this is true by using the DigitalColor Meter application.

Be careful how you interpret the results you get from DigitalColor Meter, they are the colors after the window server has done it's color matching, so you may not get the colors you expect, but they may also not be affected by the background...


I found a workaround, to fill the view with a background white before drawing the horizontal gradient paths. Unfortunately, when I add NSButtons with transparent backgrounds as subviews, they appear as white squares in the view. I've noticed that once I resize the window, so that the view redraws, the button appears correctly. However, after it is pressed and released, the white square reappears (the button is just a momentary-light button, so it should return to the initial state).

Are you sure that your embedding hierarchy is correct? You might just be getting lucky at some times and not others, and the white rectangle your drawing might just be mimicking what is already occurring in the window.


Could anyone suggest how to fix this? I've attached my subclass' drawRect method:

The attached code is really not the best way to draw a gradient. You should look up the CGShading API for how to properly do gradients (and this route is also more performant than drawing a series of lines). This is due to get a lot easier in the future, but that future isn't here yet.
--
David Duncan
Apple DTS Quartz and Printing
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: NSView subview backgrounds
      • From: Twisted Theory Software <email@hidden>
References: 
 >NSView subview backgrounds (From: Twisted Theory Software <email@hidden>)

  • Prev by Date: Re: Prevent resizing of NSWindow
  • Next by Date: Re: id type used as token and Distributed Objects
  • Previous by thread: NSView subview backgrounds
  • Next by thread: Re: NSView subview backgrounds
  • Index(es):
    • Date
    • Thread