Re: Transparent window and opaque objects
Re: Transparent window and opaque objects
- Subject: Re: Transparent window and opaque objects
- From: Lorenzo <email@hidden>
- Date: Thu, 25 Oct 2007 01:44:55 +0200
Thank you Shawn. Your suggestions made me think about the trick I used to
solve an overlapping problem. I solved it reordering the subviews.
I iterate through the subviews looking for the NSImageView obj and I store
its index. Then I delete all the subviews. Now I addSubview:NSImageView (as
first) then I add all the other objects. So the NSView gets drawn as first.
It works like a charm. Thank you so much!
Best Regards
--
Lorenzo
email: email@hidden
> From: Shawn Erickson <email@hidden>
> Date: Wed, 24 Oct 2007 15:27:24 -0700
> To: Lorenzo <email@hidden>
> Cc: email@hidden
> Subject: Re: Transparent window and opaque objects
>
> On 10/24/07, Lorenzo <email@hidden> wrote:
>> Hi,
>> I set my window with a transparent background
>>
>> [win setBackgroundColor:[NSColor clearColor]];
>> [win setOpaque:NO];
>> [win setHasShadow:NO];
>> [[win contentView] addSubview:aView];
>>
>> The aView contains an NSImageView and some white NSTextField labels.
>> The NSImageView contains a rounded corner rectangle gray image with alpha
>> 0.5. My intention is to see an half a transparent rounded corner pop-up
>> window with some pure-white text over.
>> In IB I can quite see the half-transparent picture within the NSImageView,
>> and the white text OVER the image. Instead when I launch the application,
>> the white text gets multiplied (I guess) by the image alpha value and
>> results in a dark gray color. What did I forget? Any idea?
>
> The display order of sibling views is undefined in Tiger and earlier.
> So you are likely getting your text fields rendered before the image
> view renders.
>
> I suggest that you consider using a custom view to render you
> background image in and then add your text fields as sub-views of that
> custom view.
>
> In the short term you could try to add the text fields as subviews of
> the image view (have to do that using code, IB wont help with this).
>
> -Shawn
_______________________________________________
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