-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPickers.swift
55 lines (51 loc) · 1.62 KB
/
Pickers.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
48
49
50
51
52
53
54
55
import SwiftUI
struct Pickers: View {
@State var selection: String = "Most recent"
@State var filterOptions: [String] = ["Most recent", "Most popular", "Most liked" ]
var body: some View {
VStack {
List {
Picker(selection: $selection) {
ForEach(filterOptions, id: \.self) { option in
Text(option)
.tag(option)
}
}
label: {
HStack {
Text("Filter: ")
Text(selection)
}
}
.pickerStyle(.segmented)
}
Menu {
Picker("Filter", selection: $selection) {
ForEach(filterOptions, id: \.self) { option in
HStack {
Text(option)
Image(systemName: "heart.fill")
}
.tag(option)
}
}
.pickerStyle(.inline)
} label: {
HStack {
Text("Filter:")
Text(selection)
}
.font(.headline)
.foregroundColor(.white)
.padding()
.padding(.horizontal)
.background(.blue)
.cornerRadius(10)
.shadow(color: Color.blue.opacity(0.3), radius: 10, x: 0, y: 10)
}
}
}
}
#Preview {
Pickers()
}