From f6d9d0a5379e7df9afbede684b8f9181bfdcfd65 Mon Sep 17 00:00:00 2001 From: Dylan Wreggelsworth Date: Fri, 2 Jun 2017 14:52:38 -0400 Subject: [PATCH] Fixe hex string initialization --- Colors-macOS.playground/Contents.swift | 3 + Colors-macOS.playground/timeline.xctimeline | 104 ++++++++++---------- Configs/Frameworks/Colors.plist | 2 +- Sources/Color+Conversion.swift | 7 +- 4 files changed, 60 insertions(+), 56 deletions(-) diff --git a/Colors-macOS.playground/Contents.swift b/Colors-macOS.playground/Contents.swift index db14e69..9d13a8e 100644 --- a/Colors-macOS.playground/Contents.swift +++ b/Colors-macOS.playground/Contents.swift @@ -23,6 +23,9 @@ color1 == color2 color2 == color3 var dinerGreen = Color(hex: 0x37ecbd) +var dinerGreen2 = Color(hex: "0x37ecbd") + +dinerGreen2.rgb dinerGreen.rgb dinerGreen.hsl diff --git a/Colors-macOS.playground/timeline.xctimeline b/Colors-macOS.playground/timeline.xctimeline index 71d5544..2273a0f 100644 --- a/Colors-macOS.playground/timeline.xctimeline +++ b/Colors-macOS.playground/timeline.xctimeline @@ -3,279 +3,279 @@ version = "3.0"> diff --git a/Configs/Frameworks/Colors.plist b/Configs/Frameworks/Colors.plist index 4afce27..2ec2130 100644 --- a/Configs/Frameworks/Colors.plist +++ b/Configs/Frameworks/Colors.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.9.7 + 0.9.8 CFBundleSignature ???? CFBundleVersion diff --git a/Sources/Color+Conversion.swift b/Sources/Color+Conversion.swift index d5fc9ac..cfd3358 100644 --- a/Sources/Color+Conversion.swift +++ b/Sources/Color+Conversion.swift @@ -309,9 +309,10 @@ extension Color { static func hexString2rgb(_ hex: String) -> Color { let scanner = Scanner(string: hex) - var value = 0 - scanner.scanInt(&value) - return Color(hex: value) + scanner.charactersToBeSkipped = CharacterSet(charactersIn: "#") + var value: UInt32 = 0 + scanner.scanHexInt32(&value) + return Color(hex: Int(value)) } }