UIScrollView
category to center content, enable additional zoom gestures and add getters for animated properties.
This category adds properties to enable and configure:
-
Centering the content view, even when zooming out and having the
UIScrollView
bouncing. This also works for the view returned by-viewForZoomingInScrollView:
of theUIScrollViewDelegate
when zooming. -
Double-tapping to zoom in, two-finger-tapping to zoom out and one-finger-zooming (see BDDROneFingerZoomGestureRecognizer). Properties to access the gesture recognizers are provided.
Additionally, this category adds zoomScale
, contentOffset
and contentSize
getters that return correct values when an animation is running on the UIScrollView
. These new properties are not KVO compliant but can be polled repeatedly.
This is especially useful if you use an UIScrollView
in your OpenGL View to scroll/zoom content: In your game loop you just poll the values to position and scale your rendered content.
For more info see the header.
Simply add the files in the UIScrollView+BDDRScrollViewAdditions.h
and UIScrollView+BDDRScrollViewAdditions.m
to your project or add BDDRScrollViewAdditions
to your Podfile if you're using CocoaPods.
To run the example project clone the repo and run pod install
in the Example folder.
Everything is documented in the header file. A rendered version is available on CocoaDocs.
-
Centering the content view is not done by default.
-
By default there is no support for double-tap-zoom-in, two-finger-zoom-out or one-finger-zoom gestures.
-
UIScrollView
defineszoomScale
,contentOffset
andcontentSize
but these properties don't always return the correct values whenUIScrollView
is animating, for example whenzoomBouncing
isYES
.
Follow @bddckr on Twitter.
Copyright (c) 2013-2014 Christopher - Marcel Böddecker
Licensed under The MIT License (MIT).