Skip to content

Commit d4aa63d

Browse files
authored
Remove react logbox from button and title components (#6987)
1 parent 698e78f commit d4aa63d

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

lib/ios/RNNComponentView.m

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,49 @@
11
#import "RNNComponentView.h"
22
#import "RCTHelpers.h"
33

4-
@implementation RNNComponentView
4+
@implementation RNNComponentView {
5+
BOOL _observeLayerChange;
6+
}
57

68
- (void)layoutSubviews {
79
[super layoutSubviews];
810
#ifdef DEBUG
9-
[RCTHelpers removeYellowBox:self];
11+
[self removeYellowBox];
1012
#endif
1113
}
1214

15+
#ifdef DEBUG
16+
- (void)removeYellowBox {
17+
if (self.subviews.count > 0 && self.subviews.firstObject.subviews.count > 0) {
18+
if (!_observeLayerChange) {
19+
[self.subviews.firstObject.subviews.firstObject.layer
20+
addObserver:self
21+
forKeyPath:@"sublayers"
22+
options:NSKeyValueObservingOptionNew
23+
context:nil];
24+
_observeLayerChange = YES;
25+
}
26+
27+
for (UIView *view in self.subviews.firstObject.subviews.firstObject.subviews) {
28+
if ([view.accessibilityLabel isEqualToString:@"! Yellow Box"]) {
29+
view.layer.opacity = 0;
30+
view.layer.zPosition = -100;
31+
}
32+
}
33+
}
34+
}
35+
36+
- (void)observeValueForKeyPath:(NSString *)keyPath
37+
ofObject:(id)object
38+
change:(NSDictionary *)change
39+
context:(void *)context {
40+
if ([keyPath isEqualToString:@"sublayers"]) {
41+
if (((CALayer *)object).sublayers.count > 1) {
42+
((CALayer *)object).sublayers.lastObject.opacity = 0;
43+
((CALayer *)object).sublayers.lastObject.zPosition = -100;
44+
}
45+
}
46+
}
47+
#endif
48+
1349
@end

0 commit comments

Comments
 (0)