UINavigation 栏外观色调在 iOS 16 中不起作用

Zah*_*ola 7 uikit ios swift swiftui

我正在使用 SwiftUI,目前使用以下方法全局设置导航栏后退按钮的色调颜色:

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

升级到 Xcode 14 并构建 iOS 16 模拟器后,我注意到我设置的色调现在被忽略并默认为系统蓝色色调。

我发现使用这种方法确实可以使其看起来符合预期:

let image = UIImage(systemName: "chevron.backward")?.withTintColor(.black, renderingMode: .alwaysOriginal)
appearance.setBackIndicatorImage(image, transitionMaskImage: image)
Run Code Online (Sandbox Code Playgroud)

不过,我很好奇是否有更优雅的方法来恢复 iOS 16 中全局控制色调的能力

Ron*_*ter 8

对于 iOS 16 中的 SwiftUI,要全局设置导航栏后退按钮的色调颜色,请在 Assets.xcassets 中配置 AccentColor。 在 Xcode 14 中配置 AccentColor