Skip to content

Commit

Permalink
Update UIColorExtensions.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
pkh0225 committed Nov 20, 2024
1 parent f5d335c commit 9ed3474
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Sources/SwiftHelper/UI/UIColorExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ extension UIColor {

/// Returns random UIColor with random alpha(default: false)
public static var random: UIColor {
let r: CGFloat = CGFloat(arc4random() % 11) / 10.0
let g: CGFloat = CGFloat(arc4random() % 11) / 10.0
let b: CGFloat = CGFloat(arc4random() % 11) / 10.0
return UIColor(red: r, green: g, blue: b, alpha: 1.0)
let red = CGFloat.random(in: 0...1)
let green = CGFloat.random(in: 0...1)
let blue = CGFloat.random(in: 0...1)

return UIColor(red: red, green: green, blue: blue, alpha: 1.0)
}

public func toImage(size: CGSize = CGSize(width: 1, height: 1)) -> UIImage? {
Expand Down

0 comments on commit 9ed3474

Please sign in to comment.