🙄
UIColorのlight/dark RGB
UIColor | light | opacity | dark | opacity |
---|---|---|---|---|
systemGray | 8E8E93 | 100% | 8E8E93 | 100% |
systemGray2 | AEAEB2 | 100% | 636366 | 100% |
systemGray3 | C7C7CC | 100% | 48484A | 100% |
systemGray4 | D1D1D6 | 100% | 3A3A3C | 100% |
systemGray5 | E5E5EA | 100% | 2C2C2E | 100% |
systemGray6 | F2F2F7 | 100% | 1C1C1E | 100% |
label | 000000 | 100% | FFFFFF | 100% |
secondaryLabel | 3C3C43 | 60% | EBEBF5 | 60% |
tertiaryLabel | 3C3C43 | 30% | EBEBF5 | 30% |
quaternaryLabel | 3C3C43 | 18% | EBEBF5 | 16% |
systemBackground | FFFFFF | 100% | 000000 | 100% |
secondarySystemBackground | F2F2F7 | 100% | 1C1C1E | 100% |
seconderySystemGroupedBackground | FFFFFF | 100% | 1C1C1E | 100% |
tertiarySystemBackground | FFFFFF | 100% | 2C2C2E | 100% |
let colors: [UIColor] = [
UIColor.systemGray,
UIColor.systemGray2,
UIColor.systemGray3,
UIColor.systemGray4,
UIColor.systemGray5,
UIColor.systemGray6,
UIColor.label,
UIColor.secondaryLabel,
UIColor.tertiaryLabel,
UIColor.quaternaryLabel,
UIColor.systemBackground,
UIColor.secondarySystemBackground,
UIColor.secondarySystemGroupedBackground,
UIColor.tertiarySystemBackground,
]
List {
ForEach(colors, id: \.hashValue) { color in
HStack {
Rectangle()
.frame(width: 20, height: 20)
.foregroundColor(Color(color))
Text(colorMeu(color))
Text(colorHoge(color))
}
}
}
func colorMeu(_ color: UIColor) -> String {
let meu = color.resolvedColor(with: UITraitCollection(userInterfaceStyle: .dark))
let components = meu.cgColor.components!
var str = [String]()
if components.count == 4 {
for i in (0 ..< 3) {
str.append(String(Int(components[i] * 255), radix: 16, uppercase: true))
}
str.append("\(Int(components[3] * 100))%")
} else if components.count == 2 {
str.append(String(Int(components[0] * 255), radix: 16, uppercase: true))
str.append("\(Int(components[1] * 100))%")
}
return str.joined(separator: ",")
}
func colorHoge(_ color: UIColor) -> String {
var desc = color.description
if desc.contains("name") {
desc = desc.components(separatedBy: "name = ").last!
desc.removeLast()
}
return desc
}
Discussion