Skip to content

Instantly share code, notes, and snippets.

View JTostitos's full-sized avatar

Jonathan T. JTostitos

View GitHub Profile
@JTostitos
JTostitos / LightDarkColor.swift
Last active July 29, 2024 20:42
Check if Color is Light or Dark. Returns a bool so that you can determine what color to make the text shown in front of the light color.
#if os(macOS)
typealias PlatformColor = NSColor
#else
typealias PlatformColor = UIColor
#endif
/// This was primarilly used in a SwiftUI app which is why you see the extension is on Color but theoretically, the code inside the function below could be used in just UIKit as the underlying code has nothing to do with SwiftUI.
extension Color {
func isLightColor() -> Bool? {