我正在尝试将导航标题移动到右侧而不是左侧,关于如何实现它有什么想法吗?
init() {
UINavigationBar.appearance().largeTitleTextAttributes = [.foregroundColor: UIColor.white]
}
var body: some View {
NavigationView {
Color.init("midnight blue")
.edgesIgnoringSafeArea(.vertical)
.navigationBarTitle("המרות מטבע")
.navigationBarItems(trailing:
Button(action: {
print("button pressed")
}) {
Image(systemName: "plus")
.foregroundColor(Color.orange)
})
}
}
最佳答案
我想这就是您要找的。但考虑到这是由 iOS 根据您的语言设置自动应用的。
NavigationView {
Color.init("midnight blue")
.edgesIgnoringSafeArea(.vertical)
.navigationBarTitle("המרות מטבע")
.navigationBarItems(trailing:
Button(action: {
print("button pressed")
}) {
Image(systemName: "plus")
.foregroundColor(Color.orange)
})
}.environment(\.layoutDirection, .rightToLeft)
关于ios - 从左到右更改导航标题位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59487374/