Просмотр исходного кода

Fix topBar.noBorder option on iOS 13 (#5705)

* Fix topBar.noBorder option on iOS 13

* Fix unit tests

* empty commit
Yogev Ben David 5 лет назад
Родитель
Сommit
919fa12780
No account linked to committer's email address

+ 2
- 0
lib/ios/UINavigationBar+utils.h Просмотреть файл

@@ -8,4 +8,6 @@
8 8
 
9 9
 - (void)rnn_setBackIndicatorImage:(UIImage *)image;
10 10
 
11
+- (void)rnn_showBorder:(BOOL)showBorder;
12
+
11 13
 @end

+ 11
- 0
lib/ios/UINavigationBar+utils.m Просмотреть файл

@@ -56,6 +56,17 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
56 56
     }
57 57
 }
58 58
 
59
+- (void)rnn_showBorder:(BOOL)showBorder {
60
+    if (@available(iOS 13.0, *)) {
61
+        UIColor* shadowColor = showBorder ? [[UINavigationBarAppearance new] shadowColor] : nil;
62
+        [[self getNavigaitonBarStandardAppearance] setShadowColor:shadowColor];
63
+        [[self getNavigaitonBarCompactAppearance] setShadowColor:shadowColor];
64
+        [[self getNavigaitonBarScrollEdgeAppearance] setShadowColor:shadowColor];
65
+    } else {
66
+        [self setShadowImage:showBorder ? nil : [UIImage new]];
67
+    }
68
+}
69
+
59 70
 - (void)removeTransparentView {
60 71
     UIView *transparentView = [self viewWithTag:TOP_BAR_TRANSPARENT_TAG];
61 72
     if (transparentView){

+ 1
- 5
lib/ios/UINavigationController+RNNOptions.m Просмотреть файл

@@ -36,11 +36,7 @@ const NSInteger BLUR_TOPBAR_TAG = 78264802;
36 36
 }
37 37
 
38 38
 - (void)setNavigationBarNoBorder:(BOOL)noBorder {
39
-	if (noBorder) {
40
-		[self.navigationBar setShadowImage:[[UIImage alloc] init]];
41
-	} else {
42
-		[self.navigationBar setShadowImage:nil];
43
-	}
39
+	[self.navigationBar rnn_showBorder:!noBorder];
44 40
 }
45 41
 
46 42
 - (void)setBarStyle:(UIBarStyle)barStyle {

+ 2
- 2
playground/ios/NavigationTests/RNNRootViewControllerTest.m Просмотреть файл

@@ -461,7 +461,7 @@
461 461
 	self.options.topBar.noBorder = [[Bool alloc] initWithValue:topBarNoBorderInput];
462 462
 	__unused RNNStackController* nav = [self createNavigationController];
463 463
 	[self.uut viewWillAppear:false];
464
-	XCTAssertNotNil(self.uut.navigationController.navigationBar.shadowImage);
464
+	XCTAssertNil(self.uut.navigationController.navigationBar.standardAppearance.shadowColor);
465 465
 }
466 466
 
467 467
 -(void)testTopBarNoBorderOff {
@@ -469,7 +469,7 @@
469 469
 	self.options.topBar.noBorder = [[Bool alloc] initWithValue:topBarNoBorderInput];
470 470
 	__unused RNNStackController* nav = [self createNavigationController];
471 471
 	[self.uut viewWillAppear:false];
472
-	XCTAssertNil(self.uut.navigationController.navigationBar.shadowImage);
472
+	XCTAssertEqual(self.uut.navigationController.navigationBar.standardAppearance.shadowColor, [UINavigationBarAppearance new].shadowColor);
473 473
 }
474 474
 
475 475
 -(void)testStatusBarBlurOn {