Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to change the speed of scrollRectToVisible?

Is there a way to change how quickly scrollRectToVisible animates when scrolling a UIScrollView?

like image 920
Moshe Avatar asked Nov 04 '10 20:11

Moshe


2 Answers

Just set the animation argument to NO and then perform your own animation using the UIView's animation class methods.

[UIView animateWithDuration:1.0f delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^{
    [scrollView scrollRectToVisible:viewFrame animated:NO];
} completion:nil];
like image 98
Camsoft Avatar answered Nov 10 '22 05:11

Camsoft


No, not with public methods. The duration is fixed at 0.3 seconds.

There is a private, undocumented API to change the duration:

@interface UIScrollView(UIScrollViewInternal)
-(void)_setContentOffsetAnimationDuration:(NSTimeInterval)duration;
@end

but as all undocumented API, using this will lead to rejection from AppStore.

like image 39
kennytm Avatar answered Nov 10 '22 03:11

kennytm