From e9bdcb0ffed5faeef3236ac1f7ca7123a8aad3ec Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 18 Sep 2015 18:12:12 +0800 Subject: [PATCH] share Profile with square avatar --- Yep/Extensions/UIImage+Yep.swift | 5 +++++ Yep/ViewControllers/Profile/ProfileViewController.swift | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Yep/Extensions/UIImage+Yep.swift b/Yep/Extensions/UIImage+Yep.swift index 019e7a44..506cd518 100644 --- a/Yep/Extensions/UIImage+Yep.swift +++ b/Yep/Extensions/UIImage+Yep.swift @@ -16,6 +16,11 @@ extension UIImage { return self.largestCenteredSquareImage().resizeToTargetSize(CGSize(width: radius * 2, height: radius * 2)).roundImage() } + func squareImageOfSize(size: CGFloat) -> UIImage { + let size = floor(size - Ruler.match(.iPhoneWidths(0.5, 0.5, 1.5))) + return self.largestCenteredSquareImage().resizeToTargetSize(CGSize(width: size, height: size)) + } + func largestCenteredSquareImage() -> UIImage { let scale = self.scale diff --git a/Yep/ViewControllers/Profile/ProfileViewController.swift b/Yep/ViewControllers/Profile/ProfileViewController.swift index 3e813d11..02d3107d 100644 --- a/Yep/ViewControllers/Profile/ProfileViewController.swift +++ b/Yep/ViewControllers/Profile/ProfileViewController.swift @@ -573,7 +573,8 @@ class ProfileViewController: UIViewController { avatarFileURL = NSFileManager.yepAvatarURLWithName(avatar.avatarFileName), avatarFilePath = avatarFileURL.path, image = UIImage(contentsOfFile: avatarFilePath) { - thumbnail = image.roundImageOfRadius(50) + //thumbnail = image.roundImageOfRadius(50) + thumbnail = image.squareImageOfSize(100) } }