Skip to content

Commit 013a861

Browse files
authored
Merge pull request apache#260 from bentleyo/navigation-buttons
Fix nav buttons on iOS and allow custom color
2 parents 3f0528c + 65a825a commit 013a861

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ instance, or the system browser.
138138
- __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself.
139139
- __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property.
140140
- __hidenavigationbuttons__: set to `yes` or `no` to turn the toolbar navigation buttons on or off (defaults to `no`). Only applicable if toolbar is not disabled.
141+
- __navigationbuttoncolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default color. Only applicable if navigation buttons are visible.
141142
- __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`)
142143
- __toolbarcolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default color of the toolbar. Only applicable if toolbar is not disabled.
143144
- __toolbartranslucent__: set to `yes` or `no` to make the toolbar translucent(semi-transparent) (defaults to `yes`). Only applicable if toolbar is not disabled.

src/ios/CDVInAppBrowser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
@property (nonatomic, copy) NSString* toolbarcolor;
5555
@property (nonatomic, assign) BOOL toolbartranslucent;
5656
@property (nonatomic, assign) BOOL hidenavigationbuttons;
57+
@property (nonatomic, copy) NSString* navigationbuttoncolor;
5758
@property (nonatomic, assign) BOOL clearcache;
5859
@property (nonatomic, assign) BOOL clearsessioncache;
5960

src/ios/CDVInAppBrowser.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,19 +642,24 @@ - (void)createViews
642642
self.forwardButton = [[UIBarButtonItem alloc] initWithTitle:frontArrowString style:UIBarButtonItemStylePlain target:self action:@selector(goForward:)];
643643
self.forwardButton.enabled = YES;
644644
self.forwardButton.imageInsets = UIEdgeInsetsZero;
645+
if (_browserOptions.navigationbuttoncolor != nil) { // Set button color if user sets it in options
646+
self.forwardButton.tintColor = [self colorFromHexString:_browserOptions.navigationbuttoncolor];
647+
}
645648

646649
NSString* backArrowString = NSLocalizedString(@"", nil); // create arrow from Unicode char
647650
self.backButton = [[UIBarButtonItem alloc] initWithTitle:backArrowString style:UIBarButtonItemStylePlain target:self action:@selector(goBack:)];
648651
self.backButton.enabled = YES;
649652
self.backButton.imageInsets = UIEdgeInsetsZero;
653+
if (_browserOptions.navigationbuttoncolor != nil) { // Set button color if user sets it in options
654+
self.backButton.tintColor = [self colorFromHexString:_browserOptions.navigationbuttoncolor];
655+
}
650656

651657
// Filter out Navigation Buttons if user requests so
652658
if (_browserOptions.hidenavigationbuttons) {
653659
[self.toolbar setItems:@[self.closeButton, flexibleSpaceButton]];
654660
} else {
655661
[self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]];
656662
}
657-
[self.toolbar setItems:@[self.closeButton, flexibleSpaceButton]];
658663

659664
self.view.backgroundColor = [UIColor grayColor];
660665
[self.view addSubview:self.toolbar];

0 commit comments

Comments
 (0)