how to get window with semi-transparent blurred background

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

  1. macrumors regular

    Joined:
    Jan 8, 2003
    Location:
    New York
    #1
    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: http://www.youtube.com/watch?v=zo8KPRY6-Mk
    [​IMG]


    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:

    Code:
        //  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?
    Thanks!
     

Share This Page