@@ -117,13 +117,6 @@ - (void)commonMDCBottomNavigationBarInit {
117
117
}
118
118
}
119
119
120
- UIBlurEffect *defaultBlurEffect = [UIBlurEffect effectWithStyle: _backgroundBlurEffectStyle];
121
- _blurEffectView = [[UIVisualEffectView alloc ] initWithEffect: defaultBlurEffect];
122
- _blurEffectView.hidden = !_backgroundBlurEnabled;
123
- _blurEffectView.autoresizingMask =
124
- (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
125
- [self addSubview: _blurEffectView]; // Needs to always be at the bottom
126
-
127
120
_barView = [[UIView alloc ] init ];
128
121
_barView.autoresizingMask =
129
122
(UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin);
@@ -165,7 +158,9 @@ - (void)layoutSubviews {
165
158
[super layoutSubviews ];
166
159
167
160
CGRect standardBounds = CGRectStandardize (self.bounds );
168
- self.blurEffectView .frame = standardBounds;
161
+ if (self.blurEffectView ) {
162
+ self.blurEffectView .frame = standardBounds;
163
+ }
169
164
self.barView .frame = standardBounds;
170
165
self.layer .shadowColor = self.shadowColor .CGColor ;
171
166
@@ -775,7 +770,9 @@ - (void)setBackgroundBlurEffectStyle:(UIBlurEffectStyle)backgroundBlurEffectStyl
775
770
return ;
776
771
}
777
772
_backgroundBlurEffectStyle = backgroundBlurEffectStyle;
778
- self.blurEffectView .effect = [UIBlurEffect effectWithStyle: _backgroundBlurEffectStyle];
773
+ if (self.blurEffectView ) {
774
+ self.blurEffectView .effect = [UIBlurEffect effectWithStyle: _backgroundBlurEffectStyle];
775
+ }
779
776
}
780
777
781
778
- (void )setBackgroundBlurEnabled : (BOOL )backgroundBlurEnabled {
@@ -784,7 +781,17 @@ - (void)setBackgroundBlurEnabled:(BOOL)backgroundBlurEnabled {
784
781
}
785
782
_backgroundBlurEnabled = backgroundBlurEnabled;
786
783
787
- self.blurEffectView .hidden = !_backgroundBlurEnabled;
784
+ if (_backgroundBlurEnabled & !self.blurEffectView ) {
785
+ UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle: _backgroundBlurEffectStyle];
786
+ self.blurEffectView = [[UIVisualEffectView alloc ] initWithEffect: blurEffect];
787
+ self.blurEffectView .hidden = !_backgroundBlurEnabled;
788
+ self.blurEffectView .autoresizingMask =
789
+ (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
790
+ [self insertSubview: self .blurEffectView atIndex: 0 ]; // Needs to always be at the bottom
791
+ self.blurEffectView .frame = CGRectStandardize (self.bounds );
792
+ } else if (self.blurEffectView ) {
793
+ self.blurEffectView .hidden = !_backgroundBlurEnabled;
794
+ }
788
795
}
789
796
790
797
- (void )setAlignment : (MDCBottomNavigationBarAlignment)alignment {
0 commit comments