I have an NSTableView that gets reloaded. While new data is loading, I want to add a subview ontop of it with a spinner. I would like the view ontop to be semi-transparent and r
The basic technique would be to snap an image of your view, using something like the ‑bitmapImageRepForCachingDisplayInRect:
method of NSView
, processing that image to make it blurred (Core Image is your friend here) and then overlay your view with an NSImageView
containing the blurred image.
This is fakery, of course, but that's what showmanship is about :-)
Have you tried changing the Alpha attribute for the view (for transparency)? Also here's a link on blurring a view: Blur Effect for UIView
You should check out RMBlurredView
on guthub: https://github.com/raffael/RMBlurredView
It's an easy to use subclass of NSView that does all that for you. Be sure to set setWantsLayer:YES
on your parent view!
For details, check out Cocoanetics article: http://www.cocoanetics.com/2013/10/blurring-views-on-mac/
The easiest solution—significantly more so than the -bitmapImageRepEtc:
one, and more applicable to Mac OS than the rasterization-scale method—is to set your overlay view to use a Core Animation backing layer, then give that layer a Core Image blur filter. It's a technique used all over the Mac OS, from the Dock menus to the menu bar itself. Interface Builder makes it trivially easy to set up, but you can do it in code as well, like this:
CALayer *backgroundLayer = [CALayer layer];
[backgroundView setLayer:backgroundLayer];
[backgroundView setWantsLayer:YES];
CIFilter *blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
[blurFilter setDefaults];
[backgroundView layer].backgroundFilters = [NSArray arrayWithObject:blurFilter];