Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save boominadhaprakash/f08849e92e95d73f43b4caabe7d0bf15 to your computer and use it in GitHub Desktop.
Save boominadhaprakash/f08849e92e95d73f43b4caabe7d0bf15 to your computer and use it in GitHub Desktop.
RGBtoHex Conversion Swift 4
struct RgbToHex: OptionSet {
let rawValue: Int
func convertRGBToHex(r: RawValue, g: RawValue, b: RawValue) -> String {
return String(format: "%X", (r << 16 | g << 8 | b))
}
}
let hex = RgbToHex().convertRGBToHex(r: 240, g: 200, b: 100)
print(hex)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment