【发布时间】:2020-06-17 01:21:01
【问题描述】:
我最近开始使用 SwiftUI,得出的结论是使用导航还不是很好。我想要达到的目标如下。我终于设法摆脱了半透明背景而不会导致应用程序崩溃,但现在我遇到了下一个问题。如何摆脱 navbaritem 中的“后退”文本?
我通过像这样在SceneDelegate.swift 文件中设置默认外观来实现上述视图。
let newNavAppearance = UINavigationBarAppearance()
newNavAppearance.configureWithTransparentBackground()
newNavAppearance.setBackIndicatorImage(UIImage(named: "backButton"), transitionMaskImage: UIImage(named: "backButton"))
newNavAppearance.titleTextAttributes = [
.font: UIFont(name: GTWalsheim.bold.name, size: 18)!,
.backgroundColor: UIColor.white
]
UINavigationBar.appearance().standardAppearance = newNavAppearance
我可以实现此目的的一种可能方法是覆盖导航栏项目,但是正如此问题的创建者已经说过的那样,这有一个缺点(SwiftUI Custom Back Button Text for NavigationView),在您覆盖导航栏项目后,后退手势停止工作.有了这个,我也想知道如何设置后退按钮的前景颜色。它现在具有默认的蓝色,但是我想用另一种颜色覆盖它。
【问题讨论】:
标签: ios swift navigation swiftui