Capacitor: iOS: Config param for the backgroundColor of wkWebView

Created on 26 Nov 2018  路  3Comments  路  Source: ionic-team/capacitor

If I use a dark splashscreen and test it the app on a iPhone 6 or SE I get a white flicker when the SplashScreen is handed over from the native LaunchScreen.storyboard and to the SplashScreen plugin.

The duration of the flicker depends on the phone.

This new config param would allow me to reduce the flickering for splashscreen images with a small logo in the middle and remove the flickering for splash screens with a solid color.

Entry example for capacitor.config.json

ios {
    backgroundColor: "#000000" or "rgba(0,0,0,1)" // convert it in the viewcontroller
}

rgba or hex color values are easier to configure than the UIColor.

Set the color in CAPBridgeViewController where the wkWebView is initialised.

// get config color an convert it to UIColor(
webView?.backgroundColor = //UIColor(red:0.15, green:0.17, blue:0.22, alpha:1.0)
webView?.scrollView.backgroundColor = //UIColor(red:0.15, green:0.17, blue:0.22, alpha:1.0)

For anyone using the workaround in XCode 10 do "Product / Clean Build Folder" (Cmd + Shift + K) before every build because XCode caches things and you will not see your changes.

Thx & BR, Michael

ios high

Most helpful comment

+1 for this, highly needed

All 3 comments

Other config params are described in #1097

+1 for this, highly needed

Thanks we should fix this for sure especially given the rising popularity of dark UI styles

Was this page helpful?
0 / 5 - 0 ratings

Related issues

peterpeterparker picture peterpeterparker  路  3Comments

mlynch picture mlynch  路  3Comments

alexcroox picture alexcroox  路  3Comments

danielsogl picture danielsogl  路  3Comments

daniel-lucas-silva picture daniel-lucas-silva  路  3Comments