From d81e9c498205624b211ae7f42dc4b9892bcafec0 Mon Sep 17 00:00:00 2001 From: SmengChen Date: Thu, 28 Feb 2019 10:46:49 +0800 Subject: [PATCH 1/2] Update YYTextEditExample.m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复添加到UIVisualEffectView上导致崩溃的问题 --- Demo/YYTextDemo/YYTextEditExample.m | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/Demo/YYTextDemo/YYTextEditExample.m b/Demo/YYTextDemo/YYTextEditExample.m index 7329418b..f8cfc6dc 100644 --- a/Demo/YYTextDemo/YYTextEditExample.m +++ b/Demo/YYTextDemo/YYTextEditExample.m @@ -83,7 +83,7 @@ - (void)viewDidLoad { label.text = @"Vertical:"; label.size = CGSizeMake([label.text widthForFont:label.font] + 2, toolbar.height); label.left = 10; - [toolbar addSubview:label]; + _verticalSwitch = [UISwitch new]; [_verticalSwitch sizeToFit]; @@ -99,7 +99,7 @@ - (void)viewDidLoad { _self.exclusionSwitch.enabled = !switcher.isOn; _self.textView.verticalForm = switcher.isOn; /// Set vertical form }]; - [toolbar addSubview:_verticalSwitch]; + label = [UILabel new]; label.backgroundColor = [UIColor clearColor]; @@ -107,7 +107,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]; + _debugSwitch = [UISwitch new]; [_debugSwitch sizeToFit]; @@ -118,7 +118,7 @@ - (void)viewDidLoad { [_debugSwitch addBlockForControlEvents:UIControlEventValueChanged block:^(UISwitch *switcher) { [YYTextExampleHelper setDebug:switcher.isOn]; }]; - [toolbar addSubview:_debugSwitch]; + label = [UILabel new]; label.backgroundColor = [UIColor clearColor]; @@ -126,7 +126,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]; + _exclusionSwitch = [UISwitch new]; [_exclusionSwitch sizeToFit]; @@ -136,9 +136,26 @@ - (void)viewDidLoad { [_exclusionSwitch addBlockForControlEvents:UIControlEventValueChanged block:^(UISwitch *switcher) { [_self setExclusionPathEnabled:switcher.isOn]; }]; - [toolbar addSubview:_exclusionSwitch]; + + if ([UIVisualEffectView class]) { + UIVisualEffectView *effectView = (UIVisualEffectView *)toolbar; + [effectView.contentView addSubview:label]; + [effectView.contentView addSubview:_verticalSwitch]; + [effectView.contentView addSubview:label]; + [effectView.contentView addSubview:_debugSwitch]; + [effectView.contentView addSubview:label]; + [effectView.contentView addSubview:_exclusionSwitch]; + }else{ + [toolbar addSubview:label]; + [toolbar addSubview:_verticalSwitch]; + [toolbar addSubview:label]; + [toolbar addSubview:_debugSwitch]; + [toolbar addSubview:label]; + [toolbar addSubview:_exclusionSwitch]; + } + [[YYTextKeyboardManager defaultManager] addObserver:self]; } From 47846156d090512c7c56c7c7e27cc50255de6887 Mon Sep 17 00:00:00 2001 From: SmengChen Date: Thu, 28 Feb 2019 11:23:20 +0800 Subject: [PATCH 2/2] Update YYTextAsyncExample.m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复添加到UIVisualEffectView上导致崩溃的问题 --- Demo/YYTextDemo/YYTextAsyncExample.m | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Demo/YYTextDemo/YYTextAsyncExample.m b/Demo/YYTextDemo/YYTextAsyncExample.m index 2a1246d2..bba9dd1e 100644 --- a/Demo/YYTextDemo/YYTextAsyncExample.m +++ b/Demo/YYTextDemo/YYTextAsyncExample.m @@ -133,7 +133,6 @@ - (void)viewDidLoad { YYFPSLabel *fps = [YYFPSLabel new]; fps.centerY = toolbar.height / 2; fps.left = 5; - [toolbar addSubview:fps]; UILabel *label = [UILabel new]; label.backgroundColor = [UIColor clearColor]; @@ -142,7 +141,6 @@ - (void)viewDidLoad { [label sizeToFit]; label.centerY = toolbar.height / 2; label.left = fps.right + 10; - [toolbar addSubview:label]; UISwitch *switcher = [UISwitch new]; [switcher sizeToFit]; @@ -155,7 +153,19 @@ - (void)viewDidLoad { if (!self) return; [self setAsync:switcher.isOn]; }]; - [toolbar addSubview:switcher]; + + + if ([UIVisualEffectView class]) { + UIVisualEffectView *effectView = (UIVisualEffectView *)toolbar; + [effectView.contentView addSubview:fps]; + [effectView.contentView addSubview:label]; + [effectView.contentView addSubview:switcher]; + + }else{ + [toolbar addSubview:fps]; + [toolbar addSubview:label]; + [toolbar addSubview:switcher]; + } } - (void)setAsync:(BOOL)async {