Re: NSImage/NSImageView opacity
Re: NSImage/NSImageView opacity
- Subject: Re: NSImage/NSImageView opacity
- From: Jason Coco <email@hidden>
- Date: Thu, 23 Oct 2008 21:53:38 -0400
On Oct 23, 2008, at 21:20 , Randall Meadows wrote:
I'm doing some custom drawing in a custom view, but I need to
capture that in a reflected image. So in that custom view's
subclassed -drawRect:, I'm creating an NSImage, locking focus on
that, doing all my drawing, then unlock focus. I then draw that
image as the contents of the view, and use that image in my
reflection view. It's all working perfectly, except...
The custom drawing doesn't fill up all the contents of the bounds of
the view. Specifically, a black border is left around the outside
of where I'm drawing. You can view a snapshot of what I'm talking
about at <http://www.not-pc.com/ViewBorder.png> (that's the top-
right corner of the custom view); the blue is the background, the
gray is the contents of the view I'm drawing, and the black is what
I'd like to get rid of (the blue background should show through).
I *thought* the trick to doing this was to use clearColor, so I do
this right after I create the NSImage and lock focus on it:
[[NSColor clearColor] set];
[NSBezierPath fillRect:[self bounds]];
(I create the image the same size as the view itself, so using [self
bounds] should be correct, no?)
I *also* fill the view itself with the clearColor in a similar
manner before I blast the image into it, but none of this is
working. I've also mucked about with returning YES and NO from -
isOpaque:, but that didn't make a difference either.
What am I missing to make my image transparent where I don't
actually draw anything?
How are you compositing the image when you're drawing it to the view?
Also, by "transparent" do you mean that you want the view to show
through to the background or show through to the superview? What is
drawn on the superview? Does the window have a background color,
etc... all of that is important...
J
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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