how to get window with semi-transparent blurred background

Discussion in 'Mac Programming' started by Oats, Jun 23, 2012.

  1. macrumors regular

    Jan 8, 2003
    New York
    I'd like to get a window that has a semi-transparent blurred background, just like what the Terminal can do. See this video, about 30 sec in, to see what I mean:

    I've been googling for an hour, and can't get anything to work. I believe I need to somehow create a core animation layer and add a background filter, but I've been unsuccessful so far... I just see the gray background of my window. Here's the code I've got so far:

        //  Get the content view -- everything but the titlebar.
        NSView *theView = [[self window] contentView];
        [theView setAlphaValue:0.5];
        // Create core animation layer, with filter
        CALayer *backgroundLayer = [CALayer layer];
        [theView setWantsLayer:YES];
        [theView setLayer:backgroundLayer]; 
        CIFilter *blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
        [blurFilter setDefaults];
        [theView layer].backgroundFilters = [NSArray arrayWithObject:blurFilter];  
        [[theView layer] setBackgroundFilters:[NSArray arrayWithObject:blurFilter]];
    Any tips or examples to do what I'm trying to do?

Share This Page