Programmatically scroll a UIScrollView

前端 未结 9 1161
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 15:52

I have a UIScrollView which has several views. When a user flicks their finger, the view scrolls to the right or left depending on the direction of the finger f

9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 16:15

    If you want control over the duration and style of the animation, you can do:

    [UIView animateWithDuration:2.0f delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
        scrollView.contentOffset = CGPointMake(x, y);
    } completion:NULL];
    

    Adjust the duration (2.0f) and options (UIViewAnimationOptionCurveLinear) to taste!

提交回复
热议问题