标签:ios 自定义scrollview 手势识别
1.让 scrollView不可以根据用户手指滚动
self.scrollView.scrollEnabled = NO;
2.给 scrollView添加手势
UIGestureRecognizer *gesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(dragView:)];
[self.scrollView addGestureRecognizer:gesture];
3.处理scrollView的手势
#pragma mark 手势识别器回调方法
- (void)dragView:(UIPanGestureRecognizer *)gesture{
switch (gesture.state) {
case UIGestureRecognizerStateBegan:
_startPoint = [gesture translationInView:gesture.view];
break;
case UIGestureRecognizerStateEnded:
CGPoint endPoint = [gesture translationInView:gesture.view];
if (_startPoint.x - endPoint.x > 40) {
CGPoint start = self.scrollView.contentOffset;
CGPoint end = CGPointMake(start.x + 100, 0);
[self.scrollView setContentOffset:end animated:YES];
}
break;
}
}
速递花新特性界面滑动一段后scrollView才滚动的 实现方法
标签:ios 自定义scrollview 手势识别
原文地址:http://blog.csdn.net/zhangping871/article/details/44196599