How to get current zoom level in UIScrollView?

In an attempt to create a workaround for centering the image in UIScrollView and make it behave like an Apple Photos application, I need to get the current zoom level and use it to calculate the amount that the image should be inserted into each zoom level.

(Note: I know that some programmers center the image in scrollview by centering the image in a UIView that is the same size as scrollview. This does not give good results, and I'm trying to figure out how apple made it work in the photo application. )

So, does anyone know how to get the current level of content scaling in UIScrollView?

+7
iphone center uiscrollview zoom
source share
2 answers

In OS 3.x, there is a property called zoomScale that will give you what you want. In 2.x, I believe you can look directly at the contentView transformation to get this (but this, of course, is not "official".)

+9
source share

Yes, I have your answer. I think you should use this method in your scrollViewController class.

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale{ NSLog(@"Zoomscale %f",scale); NSLog(@"Zoom End!"); } 
+13
source share

All Articles