iphone - UIScrollview - scrollRectToVisible with slow animation

前端 未结 1 1850
被撕碎了的回忆
被撕碎了的回忆 2021-02-02 12:21

I\'m using UIScrollView and using scrollRectToVisible:animated This is working fine for me. But I want to scroll to a location slowly so that user can notice the effect. Is it p

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-02 12:39

    The solution is actually pretty easy. If you use [scrollView scrollRectToVisible:frame animated:YES] the scrollview will start it's own animation, so in order to animate with your duration you have to use [scrollView scrollRectToVisible:frame animated:NO] within your animation.

    In other words: This will work.

    [UIView animateWithDuration:3 
                          delay:0 
                        options:UIViewAnimationOptionCurveEaseInOut 
                     animations:^{ [scrollView scrollRectToVisible:frame animated:NO]; } 
                     completion:NULL];
    

    0 讨论(0)
提交回复
热议问题