Fixes displaying system name in dark text (again) when remapping inputs on iOS 17

This commit is contained in:
Riley Testut 2023-06-16 15:55:51 -05:00
parent 3e858c652f
commit 69eff8fa28

View File

@ -17,7 +17,7 @@ extension UINavigationBar
}
// Make "copy" of self.
let navigationBar = UINavigationBar(frame: .zero)
let navigationBar = UINavigationBar(frame: self.bounds) // Use self.bounds to avoid "Unable to simultaneously satisfy constraints" runtime error.
navigationBar.barStyle = self.barStyle
// Set item with title so we can retrieve default text attributes.
@ -43,10 +43,20 @@ extension UINavigationBar
let containerView: UIView
//TODO: Recursively search all subviews for title UILabel instead of hardcoded OS version-specific hierarchy traversals...
if #available(iOS 16, *)
{
guard let titleControl = contentView.subviews.first(where: { NSStringFromClass(type(of: $0)).contains("Title") }) else { return nil }
containerView = titleControl
if #available(iOS 17, *)
{
guard let view = titleControl.subviews.first else { return nil }
containerView = view
}
else
{
containerView = titleControl
}
}
else
{