Skip to content

Instantly share code, notes, and snippets.

@marcuswestin
Last active December 30, 2015 23:49
Show Gist options
  • Save marcuswestin/7902892 to your computer and use it in GitHub Desktop.
Save marcuswestin/7902892 to your computer and use it in GitHub Desktop.
#import <UIKit/UIKit.h>
@interface UIView (Blur)
- (void)blur;
- (void)blur:(CGSize)size;
@end
#import "UIView+Blur.h"
@interface FunBlurView : UIView
@property UIToolbar *toolbar;
@end
@implementation FunBlurView
- (id)initWithSuperview:(UIView*)view size:(CGSize)size {
self = [super initWithFrame:CGRectMake(0, 0, size.width, size.height)];
self.clipsToBounds = YES; // toolbar draws a thin shadow on top without clip
self.toolbar = [[UIToolbar alloc] initWithFrame:[self bounds]];
[self.layer insertSublayer:[self.toolbar layer] atIndex:0];
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
[self.toolbar setFrame:[self bounds]];
}
@end
@implementation UIView (Blur)
- (void)blur {
[self blur:self.frame.size];
}
- (void)blur:(CGSize)size {
[self addSubview:[[FunBlurView alloc] initWithSuperview:self size:size]];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment