mapping UIColor to CGColor fixed

This commit is contained in:
Николай Ашанин 2016-09-29 18:40:48 +03:00
parent df79bfdb6f
commit 17f672737b
4 changed files with 9 additions and 7 deletions

BIN
LeadKit/.DS_Store vendored

Binary file not shown.

View File

@ -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)

View File

@ -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)
}
}

View File

@ -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 {