Created
April 8, 2016 20:28
-
-
Save SlayterDev/f81cc0a47b518c434a28213c3111b617 to your computer and use it in GitHub Desktop.
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
import UIKit | |
extension UIColor { | |
class func colorWithHexString(string: String) -> UIColor { | |
let num = Int(string, radix: 16)! | |
let r = CGFloat(num >> 16) / 255 | |
let g = CGFloat(((num >> 8) - (num >> 8) & 0xFF00)) / 255 | |
let b = CGFloat(num - (num & 0xFFFF00)) / 255 | |
return UIColor(red: r, green: g, blue: b, alpha: 1.0) | |
} | |
} | |
let color = UIColor.colorWithHexString("00DEAD") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment