Skip to content

Instantly share code, notes, and snippets.

@kiwiznesic
kiwiznesic / UIColor+Random.swift
Last active October 6, 2015 11:45
Get random UIColor with Swift
/*
UIColor class method that returns a random color. All parameters are optional.
*/
import UIKit
extension UIColor{
class func randomColor(hue:CGFloat? = ( CGFloat( CGFloat(arc4random()) % 256 / 256.0 ) ),
saturation:CGFloat? = ( CGFloat( CGFloat(arc4random()) % 128 / 256.0 ) + 0.5 ),
brightness:CGFloat? = ( CGFloat( CGFloat(arc4random()) % 128 / 256.0 ) + 0.5 ),