导航标题不起作用。我使用 Swift5.5.2 在预览中没有导航标题的迹象只是一个空白。
struct ContentView: View {
@State private var firstname = ""
@State private var lastname = ""
@State private var birthdate = Date()
@State private var shouldSendNewsletter = false
var body: some View {
NavigationView {
Form {
Section(header: Text("Personal Information")) {
TextField("First Name", text: $firstname)
TextField("Last Name", text: $lastname)
DatePicker("Birth Date", selection: $birthdate, displayedComponents: .date)
Section(header: Text("Actions")) {
Toggle("Send Newsletter", isOn: $shouldSendNewsletter)
}//:Actions
}
}//:Form
}//: NAVIGATION VIEW
.navigationTitle("ABC")
}
}
struct ContentView_Previews: PreviewProvider {
static var …Run Code Online (Sandbox Code Playgroud)