UINavigationBarAppearance 不适用于基于图像的栏按钮项

Mar*_*ark 6 ios swift ios13

Xcode 11.0 测试版 5 (11M382q)

当我的视图控制器之一是顶视图控制器时,我使用新的外观 API 为栏按钮项的颜色着色。我正在使用以下代码来执行此操作:

let appearance = UINavigationBarAppearance()
let attributes: [NSAttributedString.Key : Any] = [.foregroundColor : tintColor]

appearance.largeTitleTextAttributes = attributes
appearance.buttonAppearance.normal.titleTextAttributes = attributes
appearance.doneButtonAppearance.normal.titleTextAttributes = attributes

navigationItem.standardAppearance = appearance
Run Code Online (Sandbox Code Playgroud)

这似乎适用于基于文本的栏按钮项目,但基于图像的栏按钮项目保持应用程序的默认色调。这是 iOS 13 测试版中的错误吗?我已经记录了一个雷达,但只是想看看其他人是否遇到过这种情况或找到了解决方法。

正如您在下面看到的,后退箭头和加号按钮的颜色不正确。

屏幕截图显示不正确的栏按钮项目色调

小智 0

这只是未设置以下内容的情况:

UINavigationBar.appearance().barTintColor = UIColor.black
UINavigationBar.appearance().tintColor = UIColor.white
Run Code Online (Sandbox Code Playgroud)

我没有设置这些,因为我认为新的 UINavigationBarAppearance() 取代了它们,但设置这些可以解决问题。我认为这将在 GM 或未来版本中进行更新,因为混合使用新旧 API 似乎很奇怪。