-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample.swift
47 lines (43 loc) · 901 Bytes
/
Example.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
41
42
43
44
45
46
47
//
// Example.swift
// SwiftCarousel
//
// Created by JP Toro on 10/4/24.
//
import SwiftUI
struct ContentView: View {
@State private var index = 0
var body: some View {
ZStack(alignment: .bottom) {
PageView(index: $index, loops: true) {
Color.red
Color.blue
Color.purple
Color.yellow
Color.green
Color.orange
Color.indigo
} //: Carousel
HStack {
Button("Back") {
index -= 1
}
Button("Forward") {
index += 1
}
Rectangle()
.frame(width: 1, height: 20)
Button("Yellow") {
index = 3
}
} //: HStack
.padding()
.background(.white, in: .rect(cornerRadius: 12, style: .continuous))
.padding(.bottom, 25)
} //: ZStack
.ignoresSafeArea(edges: [.vertical])
}
}
#Preview {
ContentView()
}