SwiftUI TabView with PageTabViewStyle and full screen background colors

Created Aug 23 2020

SWIFT
1
import SwiftUI
2
3
struct ContentView: View {
4
@State private var selected = 0
5
6
private let colors: [Color] = [.blue, .white, .black]
7
8
var body: some View {
9
ZStack {
10
colors[selected].edgesIgnoringSafeArea(.all).animation(.easeIn)
11
TabView(selection: $selected){
12
Text("☀️").font(.title/).tag(0)
13
Text("🌦").font(.title/).tag(1)
14
Text("⛈").font(.title/).foregroundColor(Color.white).tag(2)
15
}.indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .always))
16
.tabViewStyle(PageTabViewStyle())
17
.animation(.easeIn)
18
}.statusBar(hidden: true)
19
}
20
21
22
}