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 committed by Brent Simmons
parent 6da8e15425
commit 007958f226
1 changed files with 22 additions and 0 deletions

View File

@ -81,6 +81,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 // MARK: Notifications
@objc func feedIconDidBecomeAvailable(_ note: Notification) { @objc func feedIconDidBecomeAvailable(_ note: Notification) {