SwiftUI 开发脚手架含Tab List Navigation (2020年版)
代码
import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
NavigationView {
ComponentList()
}
.tabItem {
Image(systemName: "rectangle.grid.1x2.fill")
Text("Component")
}.tag(0)
NavigationView {
Text("View Modification")
.navigationBarTitle("View Modification")
}.tabItem {
Image(systemName: "wrench.fill")
Text("View Modification")
}.tag(1)
}
.edgesIgnoringSafeArea(.top)
}
}
struct ComponentList: View {
var body: some View {
List {
Section(header: Text("User Interface")) {
NavigationLink( destination: ViewAndControls()){
Text(" Views and Controls ")
.bold()
.foregroundColor(.white)
.background(Color.purple)
.cornerRadius(6)
.shadow(radius: 4)
}
NavigationLink("View Layout and Presentation", destination: ViewLayoutAndPresentationList())
NavigationLink("Drawing and Animation", destination: DrawingAndAnimation())
Text("Framework Integration")
}
Section(header: Text("Data and Events")) {
Text("State and Data Flow")
NavigationLink("Gestures", destination: GestureSection())
}
Section(header: Text("Preview in Xcode")) {
Text("Previews")
}
}.navigationBarTitle("Component")
}
}
更多SwiftUI教程和代码关注专栏