Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SRossi

macrumors regular
Original poster
May 27, 2009
202
0
Glasgow, Scotland
Hi all again, I'm trying to change the transparency of the background of a Window. This will be done on a click of a button which is placed on the window.

Heres my code so far:

Code:
- (IBAction)changeOpacity:(id)sender
{
	NSWindow *aWindow;
	
	[aWindow setOpaque:NO];
	NSColor *semiTransparentBlue = [NSColor colorWithDeviceRed:0.0 green:0.0 blue:1.0 alpha:0.5];
	[aWindow setBackgroundColor:semiTransparentBlue];
}

PS I dont know how to set the current window to aWindow help with that would be good as well :)

Thanks all in advance

Stephen
 
Got it working my mistake, but can i ask how would I make the background change when the user moves a slider ?

Can I bind the value of the slider to the background of the window?

Stephen
 
You can observe for changes to that value in your controller, and then set the background color. See addObserver:forKeyPath:eek:ptions:context:
 
Right I created a binding in IB from a slider to a float i created but when i move the slider it creates all kind of funny numbers.

Should I create the binding programatically as kainjow says, if so is there any sample code that I could use?

Thanks.

Stephen
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.