Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the webview background color with phonegap on iOS

I recently upgraded from phonegap CLI 4.1.2 (cordova build version 3.7.0) to CLI 6.0.1 (cordova build version 4.0.1) I can see while the phonegap webview bounce works on iOS but there is a background color that can be seen underneath the app content when the bounce happens. This color has changed from black to grey after the upgrade.

How can I change this background color which I assume is the webview background color. I tried to browse through MainViewController and AppDelegate Classes/files but did not find a place where the grey color is being set. This definitely is not the color of the <body> element.

Please see the attached screenshot.

enter image description here

like image 536
DevD Avatar asked Oct 28 '25 11:10

DevD


1 Answers

Using cordova config.xml you can set a preference for the background color you want the main WebView to have, f.e.:

<preference name="BackgroundColor" value="0xff0000ff"/>

It supports a four-byte hex value, with the first byte representing the alpha channel, and standard RGB values for the following three bytes.

Read more here: https://cordova.apache.org/docs/en/latest/config_ref/index.html#preference

like image 74
choise Avatar answered Oct 31 '25 10:10

choise



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!