From 17f672737bb00ca9e69efbd31c2e51e64a5ae61f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B8=CC=86=20=D0=90?= =?UTF-8?q?=D1=88=D0=B0=D0=BD=D0=B8=D0=BD?= Date: Thu, 29 Sep 2016 18:40:48 +0300 Subject: [PATCH] mapping UIColor to CGColor fixed --- LeadKit/.DS_Store | Bin 6148 -> 6148 bytes .../UIImage/UIImage+Gradients.swift | 4 ++-- .../Extensions/UIImage/UIImage+Resize.swift | 10 ++++++---- .../UIImageView+LoadingImage.swift | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/LeadKit/.DS_Store b/LeadKit/.DS_Store index 2b1134c490d637d4b0ad82f01b53c74f22a44be1..e29d9bc7fa2d6bf65c700df38a516462566607cf 100644 GIT binary patch delta 33 pcmZoMXffE}z{r%7HhCSR+T;wzD#i($KQfB3O>E%X%+B$b9{|9^3rhe1 delta 32 ocmZoMXffE}z{n)Ac=9?%waFQbRhz$x@H1~>5@X)X&heKY0I_olUH||9 diff --git a/LeadKit/LeadKit/Extensions/UIImage/UIImage+Gradients.swift b/LeadKit/LeadKit/Extensions/UIImage/UIImage+Gradients.swift index 78c12d0e..2a95a06f 100644 --- a/LeadKit/LeadKit/Extensions/UIImage/UIImage+Gradients.swift +++ b/LeadKit/LeadKit/Extensions/UIImage/UIImage+Gradients.swift @@ -21,7 +21,7 @@ public extension UIImage { UIGraphicsBeginImageContextWithOptions(size, false, 0) let context = UIGraphicsGetCurrentContext() let colorSpace = CGColorSpaceCreateDeviceRGB() - let colors = gradientColors.map {(color: UIColor) -> AnyObject? in return color.CGColor as AnyObject? } as NSArray + let colors = gradientColors.map { return $0.CGColor } let gradient = CGGradientCreateWithColors(colorSpace, colors, nil) CGContextDrawLinearGradient(context, gradient, @@ -54,7 +54,7 @@ public extension UIImage { CGContextDrawImage(context, rect, CGImage) // Create gradient let colorSpace = CGColorSpaceCreateDeviceRGB() - let colors = gradientColors.map {(color: UIColor) -> AnyObject? in return color.CGColor as AnyObject? } as NSArray + let colors = gradientColors.map { return $0.CGColor } let gradient = CGGradientCreateWithColors(colorSpace, colors, nil) // Apply gradient CGContextClipToMask(context, rect, CGImage) diff --git a/LeadKit/LeadKit/Extensions/UIImage/UIImage+Resize.swift b/LeadKit/LeadKit/Extensions/UIImage/UIImage+Resize.swift index 46fedd49..c0ef7b22 100644 --- a/LeadKit/LeadKit/Extensions/UIImage/UIImage+Resize.swift +++ b/LeadKit/LeadKit/Extensions/UIImage/UIImage+Resize.swift @@ -71,10 +71,12 @@ public extension UIImage { guard let newContext = context else { return nil } - let newImage = UIImage(CGImage: CGBitmapContextCreateImage(newContext), - scale: scale, - orientation: imageOrientation) - return newImage + guard let cgImage = CGBitmapContextCreateImage(newContext) else { + return nil + } + return UIImage(CGImage: cgImage, + scale: scale, + orientation: imageOrientation) } } diff --git a/LeadKit/LeadKit/Extensions/UIImageView/UIImageView+LoadingImage.swift b/LeadKit/LeadKit/Extensions/UIImageView/UIImageView+LoadingImage.swift index 4e1db836..4e950627 100644 --- a/LeadKit/LeadKit/Extensions/UIImageView/UIImageView+LoadingImage.swift +++ b/LeadKit/LeadKit/Extensions/UIImageView/UIImageView+LoadingImage.swift @@ -31,7 +31,7 @@ public extension UIImageView { image = UIImage.imageFromURL(url, placeholder: placeholder, - shouldCacheImage: shouldCacheImage) { [weak self] + cacheImage: shouldCacheImage) { [weak self] (uploadedImage: UIImage?) in guard let image = uploadedImage else {