Created
August 23, 2018 07:29
-
-
Save edwardean/86b77089781eed794769674ed2867878 to your computer and use it in GitHub Desktop.
UIColor random color
This file contains hidden or 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
| extension UIColor { | |
| static var radom: UIColor { | |
| #if swift(>=4.2) | |
| return UIColor(red: .random(in: 0...1), | |
| green: .random(in: 0...1), | |
| blue: .random(in: 0...1), alpha: 1) | |
| #else | |
| return UIColor(red: CGFloat(arc4random_uniform(256) / 255), | |
| green: CGFloat(arc4random_uniform(256) / 255), | |
| blue: CGFloat(arc4random_uniform(256) / 255), alpha: 1) | |
| #endif | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment