Created
August 12, 2015 14:38
-
-
Save skreutzberger/32be80e2ebef71dfb793 to your computer and use it in GitHub Desktop.
generate random color in Swift
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
// returns a random color | |
func randomColor() -> UIColor{ | |
let red = CGFloat(drand48()) | |
let green = CGFloat(drand48()) | |
let blue = CGFloat(drand48()) | |
return UIColor(red: red, green: green, blue: blue, alpha: 1.0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Sebastian,
Does it make sense to add this method as an extension to UIColor -
so you could write " let randColor = UIColor.randomColor()?
Just an idea ;)
Daniel