@@ -205,14 +205,27 @@ extension UIColor {
205
205
let fourth = cString [ 3 ..< 4 ]
206
206
cString = " " + first + first + second + second + third + third + fourth + fourth
207
207
}
208
- var rgbValue : UInt32 = 0
209
- Scanner ( string: cString) . scanHexInt32 ( & rgbValue)
210
- self . init (
211
- red: CGFloat ( ( rgbValue & 0xFF0000 ) >> 16 ) / 255.0 ,
212
- green: CGFloat ( ( rgbValue & 0x00FF00 ) >> 8 ) / 255.0 ,
213
- blue: CGFloat ( rgbValue & 0x0000FF ) / 255.0 ,
214
- alpha: CGFloat ( 1.0 )
215
- )
208
+
209
+ if #available( iOS 13 . 0 , * ) {
210
+ var rgbValue : UInt64 = 0
211
+ Scanner ( string: cString) . scanHexInt64 ( & rgbValue)
212
+ self . init (
213
+ red: CGFloat ( ( rgbValue & 0xFF0000 ) >> 16 ) / 255.0 ,
214
+ green: CGFloat ( ( rgbValue & 0x00FF00 ) >> 8 ) / 255.0 ,
215
+ blue: CGFloat ( rgbValue & 0x0000FF ) / 255.0 ,
216
+ alpha: CGFloat ( 1.0 )
217
+ )
218
+ } else {
219
+ var rgbValue : UInt32 = 0
220
+ Scanner ( string: cString) . scanHexInt32 ( & rgbValue)
221
+ self . init (
222
+ red: CGFloat ( ( rgbValue & 0xFF0000 ) >> 16 ) / 255.0 ,
223
+ green: CGFloat ( ( rgbValue & 0x00FF00 ) >> 8 ) / 255.0 ,
224
+ blue: CGFloat ( rgbValue & 0x0000FF ) / 255.0 ,
225
+ alpha: CGFloat ( 1.0 )
226
+ )
227
+ }
228
+
216
229
} else if ( string. starts ( with: " rgba " ) ) {
217
230
let rgba = string. replacingOccurrences ( of: " rgba( " , with: " " ) . replacingOccurrences ( of: " ) " , with: " " ) . replacingOccurrences ( of: " " , with: " " ) . split ( separator: " , " )
218
231
let formatter = NumberFormatter ( )
0 commit comments