I have a WKWebView that shows a blank white screen while loading an initial URL. I would like to have an activity indicator in the middle of the screen that starts when the screen is blank and then stops when the webpage starts becoming visible. Observing the loaded
property on the web view lets me stop the activity indicator when loading is complete, but that happens after the webpage has been visible on the screen for a few seconds. I tried stopping the animation in webView(_:didCommitNavigation:)
but that stops too soon. Any ideas? I could always observe estimated progress and disappear the activity at around 80%.
There's no API that notifies you when first piece of content is displayed. You could take a snapshot of the web view and process it to see if any pixels are non-white. This would be expensive though so you would want to limit the frequency of the operation.