-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorCardView.swift
More file actions
57 lines (52 loc) · 1.51 KB
/
ColorCardView.swift
File metadata and controls
57 lines (52 loc) · 1.51 KB
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
56
57
//
// ColorCardView.swift
// SwiftUIDemo
//
// Created by 墨枫 on 2024/1/8.
//
import SwiftUI
struct ColorCardView: View {
@State private var redValue: CGFloat = 243
@State private var greenValue: CGFloat = 248
@State private var blueValue: CGFloat = 232
var body: some View {
Form {
Section {
Rectangle()
.fill(Color(
red: redValue / 255,
green: greenValue / 255,
blue: blueValue / 255)
)
.frame(height: 200)
.cornerRadius(8)
}
Section {
HStack {
Text("R: \(String(Int(redValue)))")
Slider(value: $redValue,
in: 0 ... 255,
step: 1)
.accentColor(.red)
}
HStack {
Text("G: \(String(Int(greenValue)))")
Slider(value: $greenValue,
in: 0 ... 255,
step: 1)
.accentColor(.green)
}
HStack {
Text("B: \(String(Int(blueValue)))")
Slider(value: $blueValue,
in: 0 ... 255,
step: 1)
.accentColor(.blue)
}
}
}
}
}
#Preview {
ColorCardView()
}