Skip to content

Instantly share code, notes, and snippets.

@BasThomas
Created July 30, 2024 07:34
Show Gist options
  • Save BasThomas/e5d3600011ea1a31350abb5d7dadeb92 to your computer and use it in GitHub Desktop.
Save BasThomas/e5d3600011ea1a31350abb5d7dadeb92 to your computer and use it in GitHub Desktop.
Determines color names using three different APIs
import Foundation
import SwiftUI
for _ in 1...100 {
let color = Color(
red: .random(in: 0...1),
green: .random(in: 0...1),
blue: .random(in: 0...1)
)
let name1 = AXNameFromColor(color.cgColor!)
let name2 = UIColor(color).accessibilityName
let name3 = Text("\(accessibilityName: color)")
print(color)
print(name1)
print(name2)
print(name3)
print("====")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment