Moved creation of _visualEffectView out of layoutSubviews

This commit is contained in:
Steven Lambion 2016-11-07 10:38:17 -08:00
parent abf323b288
commit 9eba3f72ac
1 changed files with 8 additions and 11 deletions

View File

@ -4,7 +4,7 @@
@implementation BlurView {
UIVisualEffectView *_visualEffectView;
BlurView *blurEffect;
UIBlurEffect * blurEffect;
}
- (void)setBlurType:(NSString *)blurType
@ -22,7 +22,13 @@
} else {
blurEffect = [BlurAmount effectWithStyle:UIBlurEffectStyleDark];
}
dispatch_async(dispatch_get_main_queue(), ^{
_visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
_visualEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_visualEffectView.frame = self.bounds;
[self insertSubview:_visualEffectView atIndex:0];
});
}
- (void)setBlurAmount:(NSNumber *)blurAmount
@ -30,13 +36,4 @@
[BlurAmount updateBlurAmount:blurAmount];
}
- (void)layoutSubviews
{
[super layoutSubviews];
_visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
_visualEffectView.frame = self.bounds;
[self insertSubview:_visualEffectView atIndex:0];
}
@end