Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions Demo/YYKitDemo/YYTextAsyncExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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];
Expand All @@ -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 {
Expand Down
36 changes: 30 additions & 6 deletions Demo/YYKitDemo/YYTextEditExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -90,15 +94,23 @@ - (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];
label.font = [UIFont systemFontOfSize:14];
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];
Expand All @@ -109,15 +121,23 @@ - (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];
label.font = [UIFont systemFontOfSize:14];
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];
Expand All @@ -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];
Expand Down