I want to zoom and scroll a UIScrollView with a CGPathRef. Because of that I assume I have to animate the UIScrollView's layer property? But which property would I animate that would make it equivalent to doing a UIView animation and setting its contentOffset property and zoomScale ?
These are not properties of a CALayer.
Any ideas as to how I would approach this? Again, just want to move the scrollview to a certain contentOffset and zoomScale, but not necessarily linearly from point A to point B, zoom A to zoom B, respectively.
I was thinking a CAKeyFrameAnimation with a CGPathRef, but I don't know which properties to animate.
Moving a CALayer around is done by (preferably) setting it's .position property - or possibly the anchorPoint (c.f. the docs on that: http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html ).
...but I don't think you want to mess with the CALayer if you're working with a UIScrollView. Have you tried applying plain CoreAnimations to your ScrollView?
(the problem is: the UIScrollView is implemented on top of CALayer - so even if you can hack it to work today, it's quite likely to break in future iOS versions. If possible, you want to avoid the CALayer for that particular class)
You have to animate the
bounds
property. In fact, that's what thecontentOffset
property uses behind the scenes.Example:
If you're curious, the way I used to get this information is the following:
The
NSLog
call will output:The
animations
snippet will list all the active animations, in this case{ bounds=<CABasicAnimation: 0xec1e7c0>; }
.Hope this helps.