Add tap gesture to your view:
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; singleTap.cancelsTouchesInView = NO; [scrollView addGestureRecognizer:singleTap];
Can be done using UIView's animateWithDuration method in the handleTap: method handleTap:
- (void)handleTap:(UITapGestureRecognizer*)gesture { __block CGRect frame = scrollView.frame; [UIView animateWithDuration:0.3 delay:0.0 options: UIViewAnimationOptionCurveLinear animations:^{ frame.origin.x += 20.0f; scrollView.frame = frame; } completion:^(BOOL finished){ scrollView.frame = frame; }]; }
source share