Procházet zdrojové kódy

Fixes backButton styling on iOS

yogevbd před 6 roky
rodič
revize
932f79bf08
1 změnil soubory, kde provedl 10 přidání a 2 odebrání
  1. 10
    2
      lib/ios/RNNBackButtonOptions.m

+ 10
- 2
lib/ios/RNNBackButtonOptions.m Zobrazit soubor

@@ -10,14 +10,14 @@
10 10
 		[viewController.navigationController.navigationBar setBackIndicatorTransitionMaskImage:[UIImage new]];
11 11
 		
12 12
 		UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:nil action:nil];
13
-		viewController.navigationItem.backBarButtonItem = backItem;
13
+		[self setBackItem:backItem onViewController:viewController];
14 14
 	} else if (self.title) {
15 15
 		UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:self.title
16 16
 																	 style:UIBarButtonItemStylePlain
17 17
 																	target:nil
18 18
 																	action:nil];
19 19
 		
20
-		viewController.navigationItem.backBarButtonItem = backItem;
20
+		[self setBackItem:backItem onViewController:viewController];
21 21
 	}
22 22
 	
23 23
 	if (self.visible) {
@@ -29,6 +29,14 @@
29 29
 	}
30 30
 }
31 31
 
32
+- (void)setBackItem:(UIBarButtonItem *)backItem onViewController:(UIViewController *)viewController {
33
+	UINavigationController* nvc = viewController.navigationController;
34
+	if (nvc.viewControllers.count >= 2) {
35
+		UIViewController* lastViewControllerInStack = nvc.viewControllers[nvc.viewControllers.count - 2];
36
+		lastViewControllerInStack.navigationItem.backBarButtonItem = backItem;
37
+	}
38
+}
39
+
32 40
 - (UIImage *)tintedIcon {
33 41
 	UIImage *image = self.icon ? [RCTConvert UIImage:self.icon] : nil;
34 42
 	if (self.color) {