Last active
December 30, 2015 23:49
-
-
Save marcuswestin/7902892 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface UIView (Blur) | |
- (void)blur; | |
- (void)blur:(CGSize)size; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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