Browse Source

Fixes backButton styling on iOS

yogevbd 6 years ago
parent
commit
932f79bf08
1 changed files with 10 additions and 2 deletions
  1. 10
    2
      lib/ios/RNNBackButtonOptions.m

+ 10
- 2
lib/ios/RNNBackButtonOptions.m View File

10
 		[viewController.navigationController.navigationBar setBackIndicatorTransitionMaskImage:[UIImage new]];
10
 		[viewController.navigationController.navigationBar setBackIndicatorTransitionMaskImage:[UIImage new]];
11
 		
11
 		
12
 		UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:nil action:nil];
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
 	} else if (self.title) {
14
 	} else if (self.title) {
15
 		UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:self.title
15
 		UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:self.title
16
 																	 style:UIBarButtonItemStylePlain
16
 																	 style:UIBarButtonItemStylePlain
17
 																	target:nil
17
 																	target:nil
18
 																	action:nil];
18
 																	action:nil];
19
 		
19
 		
20
-		viewController.navigationItem.backBarButtonItem = backItem;
20
+		[self setBackItem:backItem onViewController:viewController];
21
 	}
21
 	}
22
 	
22
 	
23
 	if (self.visible) {
23
 	if (self.visible) {
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
 - (UIImage *)tintedIcon {
40
 - (UIImage *)tintedIcon {
33
 	UIImage *image = self.icon ? [RCTConvert UIImage:self.icon] : nil;
41
 	UIImage *image = self.icon ? [RCTConvert UIImage:self.icon] : nil;
34
 	if (self.color) {
42
 	if (self.color) {