I have a UIScrollView and I'm calling scrollRectToVisible:animated:YES on it. I would like to set the speed at which it is animated. Can that be done?
A:
I don't think so. UIScrollView does not provide any delegate method or property to set this up. The animation is done somewhere you can't access without subclassing UIScrollView (which I would not recommend).
Chilloutman
2009-10-13 08:32:11
+2
A:
I ended up finding a solution. In my case, the scrolling was animated programmatically after launch, to mimic a slot machine (with 3 horizontal UIScrollViews). Was doing this with the scrollRectToVisible:animated: method.
I got to set a custom speed using UIView's beginAnimation:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:(abs(rMid-pMid)*0.3)];
scrollMid.contentOffset = CGPointMake(rMid*320, 0);
[UIView commitAnimations];
AnimationDuration depends on the distance the scroller has to move between each "drawing".
Sam V
2009-11-01 08:29:59