Skip to content

Instantly share code, notes, and snippets.

View yvesroos's full-sized avatar

Yves Roos Diehl yvesroos

View GitHub Profile
@yvesroos
yvesroos / gradient UIColors
Created March 5, 2015 21:53
Create an array of gradient colors
func degradeForPosition(topColor: UIColor, bottomColor: UIColor, totalCount: Int, position: Int) -> UIColor{
var rTop: CGFloat=0, gTop: CGFloat=0, bTop: CGFloat=0, aTop: CGFloat=0
var rBottom: CGFloat=0, gBottom: CGFloat=0, bBottom: CGFloat=0, aBottom: CGFloat=0
topColor.getRed(&rTop, green: &gTop, blue: &bTop, alpha: &aTop)
bottomColor.getRed(&rBottom, green: &gBottom, blue: &bBottom, alpha: &aBottom)
let redConst : CGFloat! = (rTop - rBottom)/CGFloat(totalCount-1)
let blueConst : CGFloat! = (bTop - bBottom)/CGFloat(totalCount-1)