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

Accepted Reply

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

  • Rincewind-san Thanks for the answer.

    However, the text color can be changed with tintColor. Is it a bug that tintColor changes the text color of the Out of process UI?

    AppDelegate.swift UINavigationBar.appearance().tintColor = .systemPink

    index.html <input type="file" name="example" accept="image/jpeg,image/png" multiple/>

  • I'm not sure Rincewind's answer is particularly helpful. If it was possible to customise the appearance of an "out of process UI" such as the image picker before, why can't we do it now? Why isn't it "guaranteed" to support our customisations? We prepare the appearance before we show the picker, so it should just work. That it doesn't suggests this is particularly flaky Apple code.

    I have an image picker that works perfectly well in iOS 14, but once you use iOS 15, it's a very light grey background with white text for the Cancel button. It looks horrible because you can barely see the button, and I can't seem to get any appearance customisations to apply to it, so it's going to look rubbish to my users.

    I don't think Rincewind's answer helps anyone?

  • Regarding tintColor, that provided in a different way than appearance customizations (which is also the reason we recommend against using the tintColor property with the appearance proxy).

    As for a deeper explanation into my answer the problem is that there really isn't one – the developers of these UIs may choose to decline appearance customizations from the host application. It is entirely possible that they meant to do that in earlier OSes and neglected to do so, or they chose to opt out in a newer OS due to other concerns. Your always free to file feedback on these cases, but traditionally these don't get reversed – opting out of appearance customizations in these cases requires effort, and so is usually done for reasons rather than on a whim.

Add a Comment

Replies

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

  • Rincewind-san Thanks for the answer.

    However, the text color can be changed with tintColor. Is it a bug that tintColor changes the text color of the Out of process UI?

    AppDelegate.swift UINavigationBar.appearance().tintColor = .systemPink

    index.html <input type="file" name="example" accept="image/jpeg,image/png" multiple/>

  • I'm not sure Rincewind's answer is particularly helpful. If it was possible to customise the appearance of an "out of process UI" such as the image picker before, why can't we do it now? Why isn't it "guaranteed" to support our customisations? We prepare the appearance before we show the picker, so it should just work. That it doesn't suggests this is particularly flaky Apple code.

    I have an image picker that works perfectly well in iOS 14, but once you use iOS 15, it's a very light grey background with white text for the Cancel button. It looks horrible because you can barely see the button, and I can't seem to get any appearance customisations to apply to it, so it's going to look rubbish to my users.

    I don't think Rincewind's answer helps anyone?

  • Regarding tintColor, that provided in a different way than appearance customizations (which is also the reason we recommend against using the tintColor property with the appearance proxy).

    As for a deeper explanation into my answer the problem is that there really isn't one – the developers of these UIs may choose to decline appearance customizations from the host application. It is entirely possible that they meant to do that in earlier OSes and neglected to do so, or they chose to opt out in a newer OS due to other concerns. Your always free to file feedback on these cases, but traditionally these don't get reversed – opting out of appearance customizations in these cases requires effort, and so is usually done for reasons rather than on a whim.

Add a Comment

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/>