2015-10-05 20:41:32 +00:00
|
|
|
#import "VibrancyView.h"
|
|
|
|
#import "BlurView.h"
|
|
|
|
#import "RCTComponent.h"
|
|
|
|
|
|
|
|
@implementation VibrancyView {
|
|
|
|
UIVisualEffectView *_visualEffectView;
|
|
|
|
UIVisualEffectView *_vibrancyView;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)layoutSubviews
|
|
|
|
{
|
|
|
|
[super layoutSubviews];
|
|
|
|
|
|
|
|
_visualEffectView.frame = self.bounds;
|
|
|
|
_vibrancyView.frame = self.bounds;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setBlurType:(NSString *)blurType {
|
|
|
|
NSArray *subviews;
|
|
|
|
if (_visualEffectView) {
|
|
|
|
[_visualEffectView removeFromSuperview];
|
|
|
|
subviews = [_vibrancyView.contentView.subviews copy];
|
|
|
|
}
|
|
|
|
|
|
|
|
UIBlurEffect *blurEffect;
|
|
|
|
|
2016-11-12 05:21:26 +00:00
|
|
|
self.clipsToBounds = true;
|
2015-10-05 20:41:32 +00:00
|
|
|
if ([blurType isEqual: @"xlight"]) {
|
|
|
|
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
|
|
|
|
} else if ([blurType isEqual: @"light"]) {
|
|
|
|
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
|
|
|
|
} else if ([blurType isEqual: @"dark"]) {
|
|
|
|
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
|
|
|
|
} else {
|
|
|
|
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
|
|
|
|
}
|
|
|
|
|
|
|
|
_visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
|
|
|
|
|
|
|
|
UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect];
|
|
|
|
_vibrancyView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];
|
|
|
|
|
|
|
|
[_visualEffectView.contentView addSubview:_vibrancyView];
|
|
|
|
|
|
|
|
if (subviews) {
|
|
|
|
for (UIView *v in subviews) {
|
|
|
|
[_vibrancyView.contentView addSubview:v];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[self addSubview:_visualEffectView];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex {
|
|
|
|
[_vibrancyView.contentView addSubview:(UIView*)subview];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|