Last active
June 15, 2019 16:28
-
-
Save Bigigrammer/13b092630d9a68ae9c2f4ee41de30e91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func adjustImageFitInScrollView(){ | |
guard let img = self.imageView.image else {return} | |
let w_scale = scrollView.frame.width / img.size.width | |
let h_scale = scrollView.frame.height / img.size.height | |
let scale = min(w_scale, h_scale) | |
scrollView.minimumZoomScale = scale | |
scrollView.setZoomScale(scale, animated: true) | |
} | |
@IBAction func showImg1(_ sender: Any) { | |
let image0 = UIImage(named: "Image") | |
imageView.image = image0 | |
imageView.frame.size = image0!.size | |
scrollView.contentSize = image0!.size | |
adjustImageFitInScrollView() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment