diff --git a/Demo/YYKitDemo/YYTextAsyncExample.m b/Demo/YYKitDemo/YYTextAsyncExample.m index e0ef80bd..66aa8a68 100644 --- a/Demo/YYKitDemo/YYTextAsyncExample.m +++ b/Demo/YYKitDemo/YYTextAsyncExample.m @@ -125,7 +125,11 @@ - (void)viewDidLoad { YYFPSLabel *fps = [YYFPSLabel new]; fps.centerY = toolbar.height / 2; fps.left = 5; - [toolbar addSubview:fps]; + if ([toolbar isKindOfClass:[UIVisualEffectView class]]) { + [[(UIVisualEffectView *)toolbar contentView] addSubview:fps]; + }else { + [toolbar addSubview:fps]; + } UILabel *label = [UILabel new]; label.backgroundColor = [UIColor clearColor]; @@ -134,7 +138,11 @@ - (void)viewDidLoad { [label sizeToFit]; label.centerY = toolbar.height / 2; label.left = fps.right + 10; - [toolbar addSubview:label]; + if ([toolbar isKindOfClass:[UIVisualEffectView class]]) { + [[(UIVisualEffectView *)toolbar contentView] addSubview:label]; + }else { + [toolbar addSubview:label]; + } UISwitch *switcher = [UISwitch new]; [switcher sizeToFit]; @@ -147,7 +155,12 @@ - (void)viewDidLoad { if (!self) return; [self setAsync:switcher.isOn]; }]; - [toolbar addSubview:switcher]; + if ([toolbar isKindOfClass:[UIVisualEffectView class]]) { + [[(UIVisualEffectView *)toolbar contentView] addSubview:switcher]; + }else { + [toolbar addSubview:switcher]; + } + } - (void)setAsync:(BOOL)async { diff --git a/Demo/YYKitDemo/YYTextEditExample.m b/Demo/YYKitDemo/YYTextEditExample.m index 88fe82ec..737ba0a0 100644 --- a/Demo/YYKitDemo/YYTextEditExample.m +++ b/Demo/YYKitDemo/YYTextEditExample.m @@ -74,7 +74,11 @@ - (void)viewDidLoad { label.text = @"Vertical:"; label.size = CGSizeMake([label.text widthForFont:label.font] + 2, toolbar.height); label.left = 10; - [toolbar addSubview:label]; + if ([toolbar isKindOfClass:[UIVisualEffectView class]]) { + [[(UIVisualEffectView *)toolbar contentView] addSubview:label]; + }else { + [toolbar addSubview:label]; + } _verticalSwitch = [UISwitch new]; [_verticalSwitch sizeToFit]; @@ -90,7 +94,11 @@ - (void)viewDidLoad { _self.exclusionSwitch.enabled = !switcher.isOn; _self.textView.verticalForm = switcher.isOn; /// Set vertical form }]; - [toolbar addSubview:_verticalSwitch]; + if ([toolbar isKindOfClass:[UIVisualEffectView class]]) { + [[(UIVisualEffectView *)toolbar contentView] addSubview:_verticalSwitch]; + }else { + [toolbar addSubview:_verticalSwitch]; + } label = [UILabel new]; label.backgroundColor = [UIColor clearColor]; @@ -98,7 +106,11 @@ - (void)viewDidLoad { label.text = @"Debug:"; label.size = CGSizeMake([label.text widthForFont:label.font] + 2, toolbar.height); label.left = _verticalSwitch.right + 5; - [toolbar addSubview:label]; + if ([toolbar isKindOfClass:[UIVisualEffectView class]]) { + [[(UIVisualEffectView *)toolbar contentView] addSubview:label]; + }else { + [toolbar addSubview:label]; + } _debugSwitch = [UISwitch new]; [_debugSwitch sizeToFit]; @@ -109,7 +121,11 @@ - (void)viewDidLoad { [_debugSwitch addBlockForControlEvents:UIControlEventValueChanged block:^(UISwitch *switcher) { [YYTextExampleHelper setDebug:switcher.isOn]; }]; - [toolbar addSubview:_debugSwitch]; + if ([toolbar isKindOfClass:[UIVisualEffectView class]]) { + [[(UIVisualEffectView *)toolbar contentView] addSubview:_debugSwitch]; + }else { + [toolbar addSubview:_debugSwitch]; + } label = [UILabel new]; label.backgroundColor = [UIColor clearColor]; @@ -117,7 +133,11 @@ - (void)viewDidLoad { label.text = @"Exclusion:"; label.size = CGSizeMake([label.text widthForFont:label.font] + 2, toolbar.height); label.left = _debugSwitch.right + 5; - [toolbar addSubview:label]; + if ([toolbar isKindOfClass:[UIVisualEffectView class]]) { + [[(UIVisualEffectView *)toolbar contentView] addSubview:label]; + }else { + [toolbar addSubview:label]; + } _exclusionSwitch = [UISwitch new]; [_exclusionSwitch sizeToFit]; @@ -127,7 +147,11 @@ - (void)viewDidLoad { [_exclusionSwitch addBlockForControlEvents:UIControlEventValueChanged block:^(UISwitch *switcher) { [_self setExclusionPathEnabled:switcher.isOn]; }]; - [toolbar addSubview:_exclusionSwitch]; + if ([toolbar isKindOfClass:[UIVisualEffectView class]]) { + [[(UIVisualEffectView *)toolbar contentView] addSubview:_exclusionSwitch]; + }else { + [toolbar addSubview:_exclusionSwitch]; + } [[YYTextKeyboardManager defaultManager] addObserver:self];