Merge pull request #40 from puelocesar/master

Fixes a crash when UIColor returns a color component with negative value
This commit is contained in:
Yannick Loriot 2017-11-16 15:35:55 +01:00 committed by GitHub
commit 2b9460a023
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

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