The background color of the navigation bar of "Photo Library" displayed by WKWebView in iOS15 does not work with the backgroudColor of UINavigationBarAppearance().
It works on iOS14.
AppDelegate.swift
if #available(iOS 15, *) {
let appearance = UINavigationBarAppearance()
appearance.backgroundColor = .red
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
UINavigationBar.appearance().compactAppearance = appearance
} else {
UINavigationBar.appearance().barTintColor = .red
}
ViewController.swift
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
webView.navigationDelegate = self
view = webView
guard let path: String = Bundle.main.path(forResource: "index", ofType: "html") else {
fatalError()
}
let myURL = URL(fileURLWithPath: path, isDirectory: false)
self.webView.loadFileURL(myURL, allowingReadAccessTo: myURL)
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sample</title>
</head>
<body>
<input type="file" name="example" accept="image/jpeg,image/png">
</body>
</html>
Version/Build
- iOS 15 RC
- Xcode 13 RC