From 1787ae4693f1700ebc0bd7d75067e3e7a14eefd4 Mon Sep 17 00:00:00 2001 From: Chris Lee Date: Tue, 23 Jan 2018 17:27:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DYYText=20Demo=20=E5=9C=A8iPho?= =?UTF-8?q?ne7=E4=B8=8A=E7=82=B9=E5=87=BBText=20Edit=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E5=B4=A9=E6=BA=83=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Demo/YYKitDemo/YYTextAsyncExample.m | 19 ++++++++++++--- Demo/YYKitDemo/YYTextEditExample.m | 36 ++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 9 deletions(-) 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];