swiftui自定义导航栏的方法
How to customize navigation bar in swiftui
如何在 swiftui 中实现这个导航栏。它看起来像默认的 .largeTitle 但是有不同的高度和右键
Navigation as needed
这是我能想到的最佳解决方案。你基本上把导航栏生成的title设置为空字符串,在导航栏的leading view中构造自己的title view
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")
})
)
}
}
}
如何在 swiftui 中实现这个导航栏。它看起来像默认的 .largeTitle 但是有不同的高度和右键 Navigation as needed
这是我能想到的最佳解决方案。你基本上把导航栏生成的title设置为空字符串,在导航栏的leading view中构造自己的title view
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")
})
)
}
}
}