From 9eba3f72ac88ed80ef096960453264e5966a2047 Mon Sep 17 00:00:00 2001 From: Steven Lambion Date: Mon, 7 Nov 2016 10:38:17 -0800 Subject: [PATCH] Moved creation of _visualEffectView out of layoutSubviews --- ios/BlurView.m | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/ios/BlurView.m b/ios/BlurView.m index 42f5740..4e502fd 100644 --- a/ios/BlurView.m +++ b/ios/BlurView.m @@ -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