Fixes a crash when UIColor returns a color component with negative value

This commit is contained in:
Paulo Cesar Ferreira 2017-11-16 12:12:26 +01:00
parent 261ffb4871
commit 9fed645d0b
1 changed files with 4 additions and 0 deletions

View File

@ -110,6 +110,10 @@ public extension DynamicColor {
*/
public final func toHex() -> UInt32 {
func roundToHex(_ x: CGFloat) -> UInt32 {
if x < 0 {
return UInt32(0)
}
let rounded: CGFloat = round(x * 255)
return UInt32(rounded)