如何在 swiftui 中实现此导航栏。它看起来像默认的.largeTitle,但是高度和右键不同 Navigation as needed
答案 0 :(得分:1)
这是我能想到的最好的解决方案。您基本上将导航栏生成的标题设置为空字符串,并在导航栏的前视图中构造自己的标题视图。
import SwiftUI
struct NavigationBarView: View {
var body: some View {
NavigationView {
Text("NavigationBarView")
.navigationBarTitle("") //Set title to none so that it won't put the bottom title
.navigationBarItems(leading:
//This is your made up title, put in the leading view so it is up top aligned with the plus button
Text("Navigation Bar").font(.largeTitle).bold()
//This is the plus button, on the right side, aka trailing view
, trailing: Button(action: {
}, label: {
Image(systemName: "plus.circle")
})
)
}
}
}