Skip to content

Instantly share code, notes, and snippets.

@zhjuncai
Created April 20, 2015 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhjuncai/c2463885436cf4e3ef61 to your computer and use it in GitHub Desktop.
Save zhjuncai/c2463885436cf4e3ef61 to your computer and use it in GitHub Desktop.
// Helper function to convert from RGB to UIColor
// UIColorFromRGB(0x22B573)
func UIColorFromRGB(rgbValue: UInt) -> UIColor {
return UIColor(
red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
alpha: CGFloat(1.0)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment