【发布时间】:2020-12-11 20:16:26
【问题描述】:
我必须将导航栏标题的最后 5 个字母更改为资产中的颜色。
struct MainView: View {
var body: some View {
NavigationView {
Text("Hello, World!")
.navigationBarTitle("HelloWorld")
}
}
init() {
// UIColor.red should be Color("orange1") and only for the last 5 letters (World)
UINavigationBar.appearance().largeTitleTextAttributes = [.foregroundColor: UIColor.red]
UINavigationBar.appearance().titleTextAttributes = [.foregroundColor: UIColor.red]
}
}
【问题讨论】:
标签: swift swiftui uinavigationbar navigationbar uinavigationbarappearance