My point is to copy the behaviour of many apps which uses photos where when UIScrollView
with UIImageView
inside is being presented it fits image to the size of screen even if this image is smaller.
I'm certain that this shouldn't be done with UIImageView
frame but manipulated by UIScrollView
but how...?
In my code I have a method called updateZoom
which calculates the minimumZoomScale
value and also assigns this value to the zoomScale
property. I guess that this is the right place to do math and calculate zoomScale
manually.
This is the method:
- (void)updateZoom {
float minZoom = MIN(self.view.bounds.size.width / self.imageView.image.size.width, self.view.bounds.size.height / self.imageView.image.size.height);
if (minZoom > 1) {
minZoom = 1;
}
self.scrollView.minimumZoomScale = minZoom;
self.scrollView.zoomScale = minZoom;
}
I hope that someone would give me a hit on how to set the zoomScale
to fit the UIScrollView
bounds.
To set the zoom which fits the image size in scrollView set the the minimumZoom for scrollView using this :
self.scrollView.minimumZoomScale = self.scrollView.frame.size.width/ self.imageView.frame.size.width;
Above code will fit your image in the scrollView Width.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With