BackgroudColor of UINavigationBarAppearance() does not work in iOS15.

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
Answered by Frameworks Engineer in 687992022

Out of process UI (such as the image picker) is not guaranteed to support your appearance customizations.

Accepted Answer

Out of process UI (such as the image picker) is not guaranteed to support your appearance customizations.

However, the text color can be changed with tintColor.

AppDelegate.swift

UINavigationBar.appearance().tintColor = .systemPink

index.html

<input type="file" name="example" accept="image/jpeg,image/png" multiple/>
BackgroudColor of UINavigationBarAppearance() does not work in iOS15.
 
 
Q