Reputation: 11
My current app is in phone gap 3.4. Can I control the status bar background colour in InAppBrowser? Any changes through status bar plugin is reflected on native pages but not on web?
Currently InAppBrowser shows its background colour on the status bar. Either I need to change the status bar colour on web or I want the InAppBrowser to start from the top of the page without leaving 20 pixel margin which will give me an iOS7 app look with status bar by default being transparent.
Upvotes: 1
Views: 8183
Reputation: 1266
Update 2018
You can pass the required toolbar color in the options like this (red):
cordova.InAppBrowser.open(url, '_blank', 'toolbar=yes,toolbarcolor=#FF0000');
Upvotes: 1
Reputation: 718
To change the colour of the status bar and navigation bar access the file CDVInAppBrowser.m
(located in ${PROJECT_ROOT}/platforms/ios/${PROJECT_NAME}/Plugins/cordova-plugin-inappbrowser/CDVInAppBrowser.m
Status Bar:
Change greenColor
to any UIColor
- (void)createViews
{
self.webView.backgroundColor = [UIColor greenColor];
}
Navigation Bar
Change redColor
to any UIColor
- (void)createViews
{
self.view.backgroundColor = [UIColor redColor];
}
Status Bar Text Colour
- (UIStatusBarStyle)preferredStatusBarStyle
{
// White
return UIStatusBarStyleLightContent;
// Or Black:
// return UIStatusBarStyleDefault;
}
Upvotes: 1
Reputation: 123
There are many options you have customizing the status bar per cordova v 3.4
Add these lines to the xml right before the
< /widget >
< preference name="StatusBarBackgroundColor" value="#ff0000" />
Run this command
cordova plugin add org.apache.cordova.statusbar
Once the plugin is loaded you can then work with the plugin via the onDeviceReady function that fires when cordova has loaded.
Example:
onDeviceReady: function () {
StatusBar.overlaysWebView(false);
StatusBar.hide();
App.phoneGapApp.receivedEvent('deviceready');
}
Hope this helped.
Upvotes: 3