From a3fca87ee524d9fe5a0dbec24278f195c6836cac Mon Sep 17 00:00:00 2001 From: Bentley O'Kane-Chase Date: Thu, 22 Feb 2018 15:09:09 +1000 Subject: [PATCH 1/2] Fix navigation buttons on iOS --- src/ios/CDVInAppBrowser.m | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index a581472..56d227b 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -654,7 +654,6 @@ } else { [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]]; } - [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton]]; self.view.backgroundColor = [UIColor grayColor]; [self.view addSubview:self.toolbar]; From 65a825a1934ef93d886225c9c56f98fcec50ef38 Mon Sep 17 00:00:00 2001 From: Bentley O'Kane-Chase Date: Wed, 21 Mar 2018 21:50:25 +1000 Subject: [PATCH 2/2] Add customisation of the navigation buttons for iOS --- README.md | 1 + src/ios/CDVInAppBrowser.h | 1 + src/ios/CDVInAppBrowser.m | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 936f1dc..3f3967b 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ instance, or the system browser. - __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself. - __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property. - __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. + - __navigationbuttoncolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default color. Only applicable if navigation buttons are visible. - __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`) - __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. - __toolbartranslucent__: set to `yes` or `no` to make the toolbar translucent(semi-transparent) (defaults to `yes`). Only applicable if toolbar is not disabled. diff --git a/src/ios/CDVInAppBrowser.h b/src/ios/CDVInAppBrowser.h index 9338c55..cb36d34 100644 --- a/src/ios/CDVInAppBrowser.h +++ b/src/ios/CDVInAppBrowser.h @@ -54,6 +54,7 @@ @property (nonatomic, copy) NSString* toolbarcolor; @property (nonatomic, assign) BOOL toolbartranslucent; @property (nonatomic, assign) BOOL hidenavigationbuttons; +@property (nonatomic, copy) NSString* navigationbuttoncolor; @property (nonatomic, assign) BOOL clearcache; @property (nonatomic, assign) BOOL clearsessioncache; diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index 56d227b..8847b44 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -642,11 +642,17 @@ self.forwardButton = [[UIBarButtonItem alloc] initWithTitle:frontArrowString style:UIBarButtonItemStylePlain target:self action:@selector(goForward:)]; self.forwardButton.enabled = YES; self.forwardButton.imageInsets = UIEdgeInsetsZero; + if (_browserOptions.navigationbuttoncolor != nil) { // Set button color if user sets it in options + self.forwardButton.tintColor = [self colorFromHexString:_browserOptions.navigationbuttoncolor]; + } NSString* backArrowString = NSLocalizedString(@"◄", nil); // create arrow from Unicode char self.backButton = [[UIBarButtonItem alloc] initWithTitle:backArrowString style:UIBarButtonItemStylePlain target:self action:@selector(goBack:)]; self.backButton.enabled = YES; self.backButton.imageInsets = UIEdgeInsetsZero; + if (_browserOptions.navigationbuttoncolor != nil) { // Set button color if user sets it in options + self.backButton.tintColor = [self colorFromHexString:_browserOptions.navigationbuttoncolor]; + } // Filter out Navigation Buttons if user requests so if (_browserOptions.hidenavigationbuttons) {