ScrollView ContentOffset & ZoomScale
As the ScrollView ZoomScale decreases or increases the maximum value of ScrollView contentOffset.X & contentOffset.Y, decreases or increases respectively. Can we deduce a relationship between ZoomScale & maximum contentOffset.x programmatically? If so, please give logic f开发者_开发问答or the same.
consider you have a UIScrollView "A" sized (100, 100) pixel
and a UIView "B" (with eventually subViews) which is its content, sized (200, 200)
when A.ZoomScale is 1 you can see just a portion of B (a rect sized 100, 100) and you can scroll B in A to change the viewable portion, doing so you change the "origin" of this viewable rect in "B", and this "origin" can be a point between (0, 0) and (100, 100). if your contentOffset.x, contentOffset.y are 100, 100 you are looking at the right/bottom quarter/portion of B. You cannot scroll to (101, 100) 'couse there's no more to see on the right of that portion.
Now you can zoom in, with A.ZoomScale = 2
that means that while A is still sized (100, 100), the content (B) is now (400, 400), so now the origin.x can go from 0 to 300 (400-300 <- content.size - A.size)
ps
you can get:
A.contentSize (it's the size of "zoomed B" and it changes depending on the zoomScale, when zoomScale = 1 it's equal to B.frame)
A.zoomScale
A.frame
精彩评论