1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Make Window background semi transparent

Discussion in 'Mac Programming' started by SRossi, Jun 22, 2009.

  1. macrumors regular

    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:

    - (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

  2. macrumors regular

    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?

  3. Moderator emeritus


    You can observe for changes to that value in your controller, and then set the background color. See addObserver:forKeyPath:eek:ptions:context:
  4. macrumors regular

    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?



Share This Page