UIScrollView zoomBouncing
@property(nonatomic, readonly, getter=isZoomBouncing) BOOL zoomBouncing
Discussion of [UIScrollView zoomBouncing]
The value of this property is YES if the scroll view is zooming back to a minimum or maximum zoom scaling value; otherwise the value is NO .
UIScrollView zoomBouncing example.
- (void)scrollViewDidEndZooming:(UIScrollView *)aScrollView withView:(UIView *)view atScale:(float)scale {
NSLog(@"scrollViewDidEndZooming: scale = %f", scale);
if (fabsf(scale - 1.0) < 1e-5) {
if (scrollView.zoomBouncing)
NSLog(@"scrollViewDidEndZooming, but zoomBouncing is still true!");
// cannot call setPagingMode now because scrollView will bounce after a call to this method, resetting contentOffset to (0, 0)
scrollViewMode = ScrollViewModeAnimatingFullZoomOut;
// however sometimes bouncing will not take place
[self performSelector:@selector(setPagingMode) withObject:nil afterDelay:0.2];
}
}
NSLog(@"scrollViewDidEndZooming: scale = %f", scale);
if (fabsf(scale - 1.0) < 1e-5) {
if (scrollView.zoomBouncing)
NSLog(@"scrollViewDidEndZooming, but zoomBouncing is still true!");
// cannot call setPagingMode now because scrollView will bounce after a call to this method, resetting contentOffset to (0, 0)
scrollViewMode = ScrollViewModeAnimatingFullZoomOut;
// however sometimes bouncing will not take place
[self performSelector:@selector(setPagingMode) withObject:nil afterDelay:0.2];
}
}
Example of [UIScrollView zoomBouncing].
- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
if (self.zoomBouncing && zoomedToScale / self.minimumZoomScale < 0.90) {
// We've let go and were under 90% of the minimum size.
self.minimumZoomScale = zoomedToScale;
[self shrinkImageToNothing];
} else {
// How far have we gone?
zoomedToScale = self.zoomScale;
}
}
if (self.zoomBouncing && zoomedToScale / self.minimumZoomScale < 0.90) {
// We've let go and were under 90% of the minimum size.
self.minimumZoomScale = zoomedToScale;
[self shrinkImageToNothing];
} else {
// How far have we gone?
zoomedToScale = self.zoomScale;
}
}