Skip to content

Instantly share code, notes, and snippets.

@fuxingloh
Created November 15, 2015 06: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 fuxingloh/a4cad3113de18056dfce to your computer and use it in GitHub Desktop.
Save fuxingloh/a4cad3113de18056dfce to your computer and use it in GitHub Desktop.
Swift: Blend 2 Color Together
class func blendColor(color1: UIColor, withColor color2: UIColor) -> UIColor {
var r1:CGFloat = 0, g1:CGFloat = 0, b1:CGFloat = 0, a1:CGFloat = 0
var r2:CGFloat = 0, g2:CGFloat = 0, b2:CGFloat = 0, a2:CGFloat = 0
color1.getRed(&r1, green: &g1, blue: &b1, alpha: &a1)
color2.getRed(&r2, green: &g2, blue: &b2, alpha: &a2)
return UIColor(red: max(r1, r2), green: max(g1, g2), blue: max(b1, b2), alpha: max(a1, a2))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment