Last active
          November 13, 2023 16:57 
        
      - 
      
- 
        Save Myrrel/f32ba2597191fc1a71fa153843c239e7 to your computer and use it in GitHub Desktop. 
    UIColor random extension
  
        
  
    
      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
    
  
  
    
  | import UIKit | |
| extension CGFloat { | |
| static func random() -> CGFloat { | |
| return CGFloat(arc4random()) / CGFloat(UInt32.max) | |
| } | |
| } | |
| extension UIColor { | |
| static func random() -> UIColor { | |
| return UIColor( | |
| red: .random(), | |
| green: .random(), | |
| blue: .random(), | |
| alpha: 1.0 | |
| ) | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment