Skip to content

Instantly share code, notes, and snippets.

@greggjaskiewicz
Created July 12, 2017 14:00
Show Gist options
  • Save greggjaskiewicz/1e95abfe1e71378e302b2d32e116b170 to your computer and use it in GitHub Desktop.
Save greggjaskiewicz/1e95abfe1e71378e302b2d32e116b170 to your computer and use it in GitHub Desktop.
how to convert int to hexadecmal colour value in swift 3
let hexColour = String(colour, radix: 16, uppercase: true)
let hexColourString = "000000\(hexColour)"
let range = hexColourString.index(hexColourString.endIndex, offsetBy: -6)..<hexColourString.endIndex
let hexHashColourString = hexColourString[range]
let textAttributeValue = "{font color='#\(hexHashColourString)'}{*font}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment