Last active
November 12, 2021 07:49
-
-
Save aqubi/4cd0aae1a732825f6f9b3a05d374835e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func toHexString4(_ color:UIColor) -> String? { | |
var cgColor:CGColor = color.cgColor | |
if let name = cgColor.colorSpace?.name, name != CGColorSpace.sRGB { | |
cgColor = color.cgColor.converted(to: CGColorSpace(name: CGColorSpace.sRGB)!, intent: .defaultIntent, options: nil)! | |
} | |
let ciColor = CIColor(cgColor: cgColor) | |
return toHexString([ciColor.red, ciColor.green, ciColor.blue, ciColor.alpha]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment