From da64f65c7b2e9b6c09ffec6e5ff033de7067c085 Mon Sep 17 00:00:00 2001 From: Flowinho Date: Thu, 12 Mar 2020 21:54:50 +0100 Subject: [PATCH] Fixes close button icon distortion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This bug was caused by an inaccessible property of UIButton. Since the button was setup in IB using a system button with a custom icon, it’s imageView property is only accessible in code. The “view” content-mode in IB is misleading here, as it affects the UIButton.view NOT UIButton.ImageView. - Set content-mode of the buttons imageview to scaleAspectFit. --- iOS/Article/ImageViewController.swift | 7 +++++++ iOS/Base.lproj/Main.storyboard | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/iOS/Article/ImageViewController.swift b/iOS/Article/ImageViewController.swift index 36eef1a3c..ceb5a524d 100644 --- a/iOS/Article/ImageViewController.swift +++ b/iOS/Article/ImageViewController.swift @@ -10,6 +10,8 @@ import UIKit class ImageViewController: UIViewController { + + @IBOutlet weak var closeButton: UIButton! @IBOutlet weak var shareButton: UIButton! @IBOutlet weak var imageScrollView: ImageScrollView! @IBOutlet weak var titleLabel: UILabel! @@ -26,6 +28,8 @@ class ImageViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + closeButton.imageView?.contentMode = .scaleAspectFit + imageScrollView.setup() imageScrollView.imageScrollViewDelegate = self imageScrollView.imageContentMode = .aspectFit @@ -58,6 +62,9 @@ class ImageViewController: UIViewController { } @IBAction func done(_ sender: Any) { + if let button = sender as? UIButton { + print(button.frame.size) + } dismiss(animated: true) } diff --git a/iOS/Base.lproj/Main.storyboard b/iOS/Base.lproj/Main.storyboard index 7880d0ddd..ad9b7cb52 100644 --- a/iOS/Base.lproj/Main.storyboard +++ b/iOS/Base.lproj/Main.storyboard @@ -265,14 +265,16 @@ -