Yes, but you should leave  the window's alpha at 1.0.

Off top of my head, it goes something like this:

Create a subclass of NSView and set that class as the class for the contentView 
of the window (in IB)

Change that class's drawRect to :

- (void)drawRect:(NSRect)rect {
    // Clear the drawing rect.
    [[NSColor clearColor] set];
    NSRectFill(rect);
}

Now any non-opague views you place within that view can decide their own alpha 
values (or draw with differing levels of alpha) as needed.

Matt

On 5 Oct 2010, at 11:25:45, Trygve Inda wrote:

> Is there a way to have a window with a 50% opaque background, but several
> odd-shaped views that are 100% opaque? The dock does this but seems be one
> window per icon. Can I do it all as one window?
> 
> My NSWindow subclass looks like:
> 
> [self setOpaque:NO];
> [self setHasShadow: YES];
> [self setLevel:NSFloatingWindowLevel];
> [self setAlphaValue:0.50];
> 
> This sets the alpha of the whole window to 50% (and works) but If I add a
> line or replace the alpha line with: [[self contentView]
> setAlphaValue:0.50];
> 
> Then the window is totally opaque... Even subviews in the main contentView.
> 
> Any way to do this w/o using multiple windows?
> 
> Trygve
> 


Trend Micro EMEA (GB) Limited, a Limited Liability Company. Registered in 
England No. 06766734. 
Registered office: Eversheds House, 70 Great Bridgewater Street, Manchester, M1 
5ES
Trend Micro (UK) Limited, a Limited Liability Company. Registered in England 
No. 3698292. 
Registered Office: Pacific House, Third Avenue, Globe Business Park, Marlow, 
Bucks, SL7 1YL 
Telephone: +44 1628 400500 Facsimile: +44 1628 400511

This communication and any accompanying files and attachments are intended only 
for the recipient to whom it is addressed. 
If you have received this communication in error, please immediately notify the 
Sender. You are further notified that any disclosure, 
copying or other distribution of this communication, including its attachments 
is strictly prohibited.
_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to