如何在swiftui中实现这个导航栏。它看起来像默认的.largeTitle,但有不同的高度和右键 Navigation as needed
最佳答案
这是我能想到的最好的解决方案。您基本上将导航栏生成的标题设置为空字符串,并在导航栏的前导 View 中构建您自己的标题 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")
})
)
}
}
}
关于swift - 如何在swiftui中自定义导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57736886/