Created
November 15, 2015 06:26
-
-
Save fuxingloh/a4cad3113de18056dfce to your computer and use it in GitHub Desktop.
Swift: Blend 2 Color Together
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
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