Created
February 2, 2018 07:35
-
-
Save boominadhaprakash/f08849e92e95d73f43b4caabe7d0bf15 to your computer and use it in GitHub Desktop.
RGBtoHex Conversion Swift 4
This file contains hidden or 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
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