2015-10-05 20:41:32 +00:00
|
|
|
#import "BlurView.h"
|
2016-10-27 07:19:43 +00:00
|
|
|
#import "BlurAmount.m"
|
|
|
|
|
2015-10-05 20:41:32 +00:00
|
|
|
|
|
|
|
@implementation BlurView {
|
|
|
|
UIVisualEffectView *_visualEffectView;
|
2016-11-07 18:38:17 +00:00
|
|
|
UIBlurEffect * blurEffect;
|
2015-10-05 20:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setBlurType:(NSString *)blurType
|
|
|
|
{
|
|
|
|
if (_visualEffectView) {
|
|
|
|
[_visualEffectView removeFromSuperview];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([blurType isEqual: @"xlight"]) {
|
2016-10-27 07:19:43 +00:00
|
|
|
blurEffect = [BlurAmount effectWithStyle:UIBlurEffectStyleExtraLight];
|
2015-10-05 20:41:32 +00:00
|
|
|
} else if ([blurType isEqual: @"light"]) {
|
2016-10-27 07:19:43 +00:00
|
|
|
blurEffect = [BlurAmount effectWithStyle:UIBlurEffectStyleLight];
|
2015-10-05 20:41:32 +00:00
|
|
|
} else if ([blurType isEqual: @"dark"]) {
|
2016-10-27 07:19:43 +00:00
|
|
|
blurEffect = [BlurAmount effectWithStyle:UIBlurEffectStyleDark];
|
2015-10-05 20:41:32 +00:00
|
|
|
} else {
|
2016-10-27 07:19:43 +00:00
|
|
|
blurEffect = [BlurAmount effectWithStyle:UIBlurEffectStyleDark];
|
2015-10-05 20:41:32 +00:00
|
|
|
}
|
2016-11-07 18:38:17 +00:00
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
_visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
|
|
|
|
_visualEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
|
|
_visualEffectView.frame = self.bounds;
|
|
|
|
[self insertSubview:_visualEffectView atIndex:0];
|
|
|
|
});
|
2015-10-05 20:41:32 +00:00
|
|
|
}
|
|
|
|
|
2016-10-27 07:19:43 +00:00
|
|
|
- (void)setBlurAmount:(NSNumber *)blurAmount
|
2015-10-05 20:41:32 +00:00
|
|
|
{
|
2016-11-02 12:01:22 +00:00
|
|
|
[BlurAmount updateBlurAmount:blurAmount];
|
2016-10-27 07:19:43 +00:00
|
|
|
}
|
2015-10-05 20:41:32 +00:00
|
|
|
|
|
|
|
@end
|