|
@@ -1,12 +1,23 @@
|
1
|
1
|
#import "RNNBackButtonOptions.h"
|
|
2
|
+#import "UIImage+tint.h"
|
2
|
3
|
|
3
|
4
|
@implementation RNNBackButtonOptions
|
4
|
5
|
|
5
|
6
|
- (void)applyOn:(UIViewController *)viewController {
|
6
|
7
|
if (self.icon) {
|
7
|
|
- UIImage *image = self.icon ? [RCTConvert UIImage:self.icon] : nil;
|
8
|
|
- [viewController.navigationController.navigationBar setBackIndicatorImage:image];
|
9
|
|
- [viewController.navigationController.navigationBar setBackIndicatorTransitionMaskImage:image];
|
|
8
|
+ UIImage *image = self.tintedIcon;
|
|
9
|
+ [viewController.navigationController.navigationBar setBackIndicatorImage:[UIImage new]];
|
|
10
|
+ [viewController.navigationController.navigationBar setBackIndicatorTransitionMaskImage:[UIImage new]];
|
|
11
|
+
|
|
12
|
+ UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:nil action:nil];
|
|
13
|
+ viewController.navigationItem.backBarButtonItem = backItem;
|
|
14
|
+ } else if (self.title) {
|
|
15
|
+ UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:self.title
|
|
16
|
+ style:UIBarButtonItemStylePlain
|
|
17
|
+ target:nil
|
|
18
|
+ action:nil];
|
|
19
|
+
|
|
20
|
+ viewController.navigationItem.backBarButtonItem = backItem;
|
10
|
21
|
}
|
11
|
22
|
|
12
|
23
|
if (self.visible) {
|
|
@@ -16,15 +27,15 @@
|
16
|
27
|
if (self.showTitle && ![self.showTitle boolValue]) {
|
17
|
28
|
self.title = @"";
|
18
|
29
|
}
|
19
|
|
-
|
20
|
|
- if (self.title) {
|
21
|
|
- UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:self.title
|
22
|
|
- style:UIBarButtonItemStylePlain
|
23
|
|
- target:nil
|
24
|
|
- action:nil];
|
25
|
|
-
|
26
|
|
- viewController.navigationItem.backBarButtonItem = backItem;
|
|
30
|
+}
|
|
31
|
+
|
|
32
|
+- (UIImage *)tintedIcon {
|
|
33
|
+ UIImage *image = self.icon ? [RCTConvert UIImage:self.icon] : nil;
|
|
34
|
+ if (self.color) {
|
|
35
|
+ return [[image withTintColor:[RCTConvert UIColor:self.color]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
27
|
36
|
}
|
|
37
|
+
|
|
38
|
+ return image;
|
28
|
39
|
}
|
29
|
40
|
|
30
|
41
|
@end
|