Skip to content

Instantly share code, notes, and snippets.

@acrookston
Created April 26, 2017 22:26
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 acrookston/cd3283ddaa94148029ff030223bc711e to your computer and use it in GitHub Desktop.
Save acrookston/cd3283ddaa94148029ff030223bc711e to your computer and use it in GitHub Desktop.
UIColor extension for creating UIColor with rgba() values
import UIKit
extension UIColor {
static func rgba(_ r: CGFloat, _ g: CGFloat, _ b: CGFloat, _ a: CGFloat) -> UIColor {
return UIColor(red: r / 255.0, green: g / 255.0, blue: b / 255.0, alpha: a)
}
static var lightBackground: UIColor { return .rgba(246, 246, 246, 1) }
static var text: UIColor { return .rgba(51, 51, 51, 1) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment