From 3716f573801d9f3631c0ac8370df5bc9395984f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=BB=B4?= Date: Wed, 21 Nov 2018 15:06:48 +0800 Subject: [PATCH] fix [Text Edit page] UIVisualEffectView should not add subviews directly to the visual effect view itself --- Demo/YYKitDemo/YYTextEditExample.m | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Demo/YYKitDemo/YYTextEditExample.m b/Demo/YYKitDemo/YYTextEditExample.m index 88fe82ec..343a4c8f 100644 --- a/Demo/YYKitDemo/YYTextEditExample.m +++ b/Demo/YYKitDemo/YYTextEditExample.m @@ -30,10 +30,13 @@ - (void)viewDidLoad { __weak typeof(self) _self = self; UIView *toolbar; + UIView *containerView ; if ([UIVisualEffectView class]) { toolbar = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight]]; + containerView = ((UIVisualEffectView *)toolbar).contentView; } else { toolbar = [UIToolbar new]; + containerView = toolbar; } toolbar.size = CGSizeMake(kScreenWidth, 40); toolbar.top = kiOS7Later ? 64 : 0; @@ -74,7 +77,7 @@ - (void)viewDidLoad { label.text = @"Vertical:"; label.size = CGSizeMake([label.text widthForFont:label.font] + 2, toolbar.height); label.left = 10; - [toolbar addSubview:label]; + [containerView addSubview:label]; _verticalSwitch = [UISwitch new]; [_verticalSwitch sizeToFit]; @@ -90,7 +93,7 @@ - (void)viewDidLoad { _self.exclusionSwitch.enabled = !switcher.isOn; _self.textView.verticalForm = switcher.isOn; /// Set vertical form }]; - [toolbar addSubview:_verticalSwitch]; + [containerView addSubview:_verticalSwitch]; label = [UILabel new]; label.backgroundColor = [UIColor clearColor]; @@ -98,7 +101,7 @@ - (void)viewDidLoad { label.text = @"Debug:"; label.size = CGSizeMake([label.text widthForFont:label.font] + 2, toolbar.height); label.left = _verticalSwitch.right + 5; - [toolbar addSubview:label]; + [containerView addSubview:label]; _debugSwitch = [UISwitch new]; [_debugSwitch sizeToFit]; @@ -109,7 +112,7 @@ - (void)viewDidLoad { [_debugSwitch addBlockForControlEvents:UIControlEventValueChanged block:^(UISwitch *switcher) { [YYTextExampleHelper setDebug:switcher.isOn]; }]; - [toolbar addSubview:_debugSwitch]; + [containerView addSubview:_debugSwitch]; label = [UILabel new]; label.backgroundColor = [UIColor clearColor]; @@ -117,7 +120,7 @@ - (void)viewDidLoad { label.text = @"Exclusion:"; label.size = CGSizeMake([label.text widthForFont:label.font] + 2, toolbar.height); label.left = _debugSwitch.right + 5; - [toolbar addSubview:label]; + [containerView addSubview:label]; _exclusionSwitch = [UISwitch new]; [_exclusionSwitch sizeToFit]; @@ -127,7 +130,7 @@ - (void)viewDidLoad { [_exclusionSwitch addBlockForControlEvents:UIControlEventValueChanged block:^(UISwitch *switcher) { [_self setExclusionPathEnabled:switcher.isOn]; }]; - [toolbar addSubview:_exclusionSwitch]; + [containerView addSubview:_exclusionSwitch]; [[YYTextKeyboardManager defaultManager] addObserver:self];