Skip to content

Commit 837f4b4

Browse files
committed
WebView in dark mode: black backgroundColor while loading
1 parent f70e317 commit 837f4b4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Sources/InAppSettingsKit/Controllers/IASKAppSettingsWebViewController.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,14 @@ - (void)viewDidLoad {
175175
self.webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:self.webViewConfiguration];
176176
self.webView.translatesAutoresizingMaskIntoConstraints = NO; // Disable autoresizing mask for layout constraints
177177
self.webView.navigationDelegate = self;
178-
179-
// Set other Xcode Interface Builder properties directly on webView:
178+
self.webView.opaque = NO;
179+
if (@available(iOS 13.0, *)) {
180+
self.webView.backgroundColor = UIColor.systemBackgroundColor;
181+
self.webView.backgroundColor = UIColor.systemBackgroundColor;
182+
self.webView.scrollView.backgroundColor = UIColor.systemBackgroundColor;
183+
} else {
184+
self.webView.backgroundColor = UIColor.whiteColor;
185+
}
180186
self.webView.allowsBackForwardNavigationGestures = YES; // Interaction: Back/Forward Gestures
181187
if (@available(iOS 16.0, *)) {
182188
self.webView.findInteractionEnabled = YES; // Interaction: Find & Replace
@@ -357,6 +363,8 @@ - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigat
357363
self.title = self.customTitle.length ? self.customTitle : result;
358364
}];
359365

366+
self.webView.scrollView.backgroundColor = nil;
367+
self.webView.opaque = YES;
360368

361369
// Update button states when loading finishes:
362370
[self updateNavigationButtons];

0 commit comments

Comments
 (0)