Tag Archives: HEX Code

Swift UIColor utilities : Random Hex colour codes, Random UIColor

Simple to use swift functions which are very useful in development and testing. 1. Generating random UIColor in Swift: Function returns random UIColor each time func randomUIColor(alpha:CGFloat!)-> UIColor { return UIColor.init(red:(CGFloat(arc4random_uniform(256))/255.0), green:CGFloat(arc4random_uniform(256))/255.0, blue: (CGFloat(arc4random_uniform(256))/255.0), alpha: alpha) } 2.Random HEX Color code in Swift 3: Function returns random 3 char Hex… Read more »