Created
November 15, 2015 19:26
-
-
Save alsedi/b845523c6bbe49eb75db to your computer and use it in GitHub Desktop.
Shorthand to create UIColor from Int values 0-255
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 Foundation | |
import UIKit | |
extension UIColor { | |
static func RGBA(r:Int, _ g: Int, _ b:Int, _ a:Int) -> UIColor { | |
return UIColor(red: CGFloat(r)/255.0, green: CGFloat(g)/255.0, blue: CGFloat(b)/255.0, alpha: CGFloat(a)/100.0) | |
} | |
static func RGB(r:Int, _ g: Int, _ b:Int) -> UIColor { | |
return UIColor.RGBA(r, g, b, 100) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment