Working from a new project: iOS > Application > Game > SpriteKit, Swift, iPhone
Here I\'ve written a function in my G
It probably has to do with a mismatch between Float and Double. Basically, if the arguments are expected to be CGFloats, you need to pass CGFloats.
let color = UIColor(red: CGFloat(red), green: CGFloat(green), blue: CGFloat(blue), alpha: CGFloat(alpha))
What's important to understand here is that CGFloat is defined as Float on 32 bit platforms, and Double on 64 bit platforms. So, if you're explicitly using Floats, Swift won't have a problem with this on 32 Bit platforms, but will produce an error on 64 bit.
See from the source code you should use CGFloat instead of Float
this should work
func colorize (hex: Int, alpha: Double = 1.0) -> UIColor {
let red = Double((hex & 0xFF0000) >> 16) / 255.0
let green = Double((hex & 0xFF00) >> 8) / 255.0
let blue = Double((hex & 0xFF)) / 255.0
var color: UIColor = UIColor( red: CGFloat(red), green: CGFloat(green), blue: CGFloat(blue), alpha:CGFloat(alpha) )
return color
}