Fixes a crash when UIColor returns a color component with negative value
This commit is contained in:
parent
261ffb4871
commit
9fed645d0b
|
@ -110,6 +110,10 @@ public extension DynamicColor {
|
||||||
*/
|
*/
|
||||||
public final func toHex() -> UInt32 {
|
public final func toHex() -> UInt32 {
|
||||||
func roundToHex(_ x: CGFloat) -> UInt32 {
|
func roundToHex(_ x: CGFloat) -> UInt32 {
|
||||||
|
if x < 0 {
|
||||||
|
return UInt32(0)
|
||||||
|
}
|
||||||
|
|
||||||
let rounded: CGFloat = round(x * 255)
|
let rounded: CGFloat = round(x * 255)
|
||||||
|
|
||||||
return UInt32(rounded)
|
return UInt32(rounded)
|
||||||
|
|
Loading…
Reference in New Issue