Fix for scroll indicators on iOS when using Dark Mode

This commit is contained in:
Maurice Parker
2023-10-10 20:28:26 -05:00
parent 455fd082ea
commit 269d0535bd

View File

@@ -82,6 +82,28 @@ class WebViewController: UIViewController {
}
override func viewWillAppear(_ animated: Bool) {
updateScrollIndicatorStyle()
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
updateScrollIndicatorStyle()
}
// See https://shadowfacts.net/2022/wkwebview-scroll-indicators-again/ for why this is necessary.
private func updateScrollIndicatorStyle() {
guard #available(iOS 15.4, *) else {
return
}
if traitCollection.userInterfaceStyle == .dark {
webView?.scrollView.indicatorStyle = .white
} else {
webView?.scrollView.indicatorStyle = .black
}
}
// MARK: Notifications
@objc func webFeedIconDidBecomeAvailable(_ note: Notification) {