forked from ole/swiftui-view-lifecycle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCaseStudyTabView.swift
40 lines (38 loc) · 1.3 KB
/
CaseStudyTabView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import SwiftUI
struct CaseStudyTabView: View {
var body: some View {
TabView {
VStack {
LifecycleMonitor(label: "Tab 1")
Text("`TabView` initializes the state for each tab’s content view all at once when it first appears. `onAppear` and `onDisappear` get called as you switch between tabs. State of offscreen tabs is kept alive.")
.font(.callout)
.frame(maxWidth: .infinity, alignment: .leading)
}
.padding()
.tabItem {
Label("Tab 1", systemImage: "1.circle")
}
LifecycleMonitor(label: "Tab 2")
.padding()
.tabItem {
Label("Tab 2", systemImage: "2.circle")
}
LifecycleMonitor(label: "Tab 3")
.padding()
.tabItem {
Label("Tab 3", systemImage: "3.circle")
}
LifecycleMonitor(label: "Tab 4")
.padding()
.tabItem {
Label("Tab 4", systemImage: "4.circle")
}
}
.navigationTitle("TabView")
}
}
struct CaseStudyTabView_Previews: PreviewProvider {
static var previews: some View {
CaseStudyTabView()
}
}