From fb525bd64152d1a6a49057bfc6de872944a2fa5b Mon Sep 17 00:00:00 2001 From: Laeyoung Chang Date: Mon, 15 May 2017 18:35:48 +0900 Subject: [PATCH] fix the bug(#24) on resize() --- Sources/ImageHelper.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/ImageHelper.swift b/Sources/ImageHelper.swift index 911fba3..bf24f83 100644 --- a/Sources/ImageHelper.swift +++ b/Sources/ImageHelper.swift @@ -335,7 +335,7 @@ public extension UIImage { - Returns A new image */ - func resize(toSize: CGSize, contentMode: UIImageContentMode = .scaleToFill) -> UIImage? { + func resize(size: CGSize, contentMode: UIImageContentMode = .scaleToFill) -> UIImage? { let horizontalRatio = size.width / self.size.width; let verticalRatio = size.height / self.size.height; var ratio: CGFloat! @@ -349,7 +349,7 @@ public extension UIImage { ratio = min(horizontalRatio, verticalRatio) } - let rect = CGRect(x: 0, y: 0, width: size.width * ratio, height: size.height * ratio) + let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height) // Fix for a colorspace / transparency issue that affects some types of // images. See here: http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/comment-page-2/#comment-39951