IOS/SwiftUI
(SwiftUI)11.탭뷰
프린이0218
2021. 4. 28. 14:06
//
// Tab01.swift
// TabBar_Tutorial
//
// Created by devdepot on 2021/04/28.
//
import SwiftUI
struct tab01: View {
var body: some View{
TabView{
//보여질 화면
MyTab01()
.background(Color.blue)
.tabItem {
Image(systemName: "airplane")
Text("1번")
}
.tag(0)
MyTab02()
.tabItem {
Image(systemName: "flame.fill")
Text("2번")
}
.tag(1)
MyTab03()
.tabItem {
Image(systemName: "doc.fill")
Text("3번")
}
.tag(2)
}
}
}
struct MyTab01: View {
var body: some View{
GeometryReader{ geo in
HStack{
Spacer()
VStack{
Spacer()
Text("1번")
.font(.largeTitle)
.fontWeight(.bold)
.foregroundColor(Color.white)
Spacer()
}
Spacer()
}
}.background(Color.blue)
.edgesIgnoringSafeArea(.all)
}
}
struct MyTab02: View {
var body: some View{
GeometryReader{ geo in
HStack{
Spacer()
VStack{
Spacer()
Text("2번")
.font(.largeTitle)
.fontWeight(.bold)
.foregroundColor(Color.white)
Spacer()
}
Spacer()
}
}.background(Color.orange)
.edgesIgnoringSafeArea(.all)
}
}
struct MyTab03: View {
var body: some View{
GeometryReader{ geo in
HStack{
Spacer()
VStack{
Spacer()
Text("3번")
.font(.largeTitle)
.fontWeight(.bold)
.foregroundColor(Color.white)
Spacer()
}
Spacer()
}
}.background(Color.green)
.edgesIgnoringSafeArea(.all)
}
}
struct tab01_Previews: PreviewProvider {
static var previews: some View {
tab01()
}
}