Created
December 16, 2014 02:10
-
-
Save evgeniyd/667cd101c700c85c72df to your computer and use it in GitHub Desktop.
A shorthand for creating UIColor object from components
This file contains 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 colorWithComponents(red redComponent: Float, green: Float, blue: Float, alpha: Float) -> UIColor { | |
let r: CGFloat = CGFloat(redComponent/255.0) | |
let g: CGFloat = CGFloat(green/255.0) | |
let b: CGFloat = CGFloat(blue/255.0) | |
let a: CGFloat = CGFloat(alpha) | |
return UIColor(red: r, green: g, blue: b, alpha: a) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment