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-10-27 07:19:43 +00:00
|
|
|
BlurView *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-10-27 07:19:43 +00:00
|
|
|
- (void)setBlurAmount:(NSNumber *)blurAmount
|
2015-10-05 20:41:32 +00:00
|
|
|
{
|
2016-10-27 07:19:43 +00:00
|
|
|
blurEffect = [BlurAmount updateBlurAmount:blurAmount];
|
|
|
|
}
|
2015-10-05 20:41:32 +00:00
|
|
|
|
2016-10-27 07:19:43 +00:00
|
|
|
|
|
|
|
- (void)layoutSubviews
|
|
|
|
{
|
|
|
|
[super layoutSubviews];
|
|
|
|
_visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
|
2015-10-05 20:41:32 +00:00
|
|
|
_visualEffectView.frame = self.bounds;
|
|
|
|
[self insertSubview:_visualEffectView atIndex:0];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|