SwiftUI How to Implement a TabView with TabItem
ContentView.swift
//
// ContentView.swift
// Test
//
// Created by Cairocoders
//
import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
FirstView()
.tabItem {
Label("Search", systemImage: "magnifyingglass")
}
SecondView()
.tabItem {
Label("Home", systemImage: "house")
}
ThirdView()
.tabItem {
Label("Profile", systemImage: "person")
}
}
} // End Body
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
FirstView.swift
//
// FirstView.swift
// Test
//
// Created by Cairocoders
//
import SwiftUI
struct FirstView: View {
var body: some View {
Text("FirstView")
}
}
struct FirstView_Previews: PreviewProvider {
static var previews: some View {
FirstView()
}
}
SecondView.swift
//
// SecondView.swift
// Test
//
// Created by Cairocoders
//
import SwiftUI
struct SecondView: View {
var body: some View {
Text("SecondView")
}
}
struct SecondView_Previews: PreviewProvider {
static var previews: some View {
SecondView()
}
}
ThirdView.swift
//
// ThirdView.swift
// Test
//
// Created by Cairocoders
//
import SwiftUI
struct ThirdView: View {
var body: some View {
Text("ThirdView")
}
}
struct ThirdView_Previews: PreviewProvider {
static var previews: some View {
ThirdView()
}
}
VIDEO