Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions WMPageController/WMMenuView/WMScrollView+ScrollBack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// WMScrollView+ScrollBack.h
// KXLive
//
// Created by 林祖涵 on 2018/11/29.
// Copyright © 2018 ibobei. All rights reserved.
//

#import "WMScrollView.h"

NS_ASSUME_NONNULL_BEGIN

@interface WMScrollView (ScrollBack)

@end

NS_ASSUME_NONNULL_END
32 changes: 32 additions & 0 deletions WMPageController/WMMenuView/WMScrollView+ScrollBack.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// WMScrollView+ScrollBack.m
// KXLive
//
// Created by 林祖涵 on 2018/11/29.
// Copyright © 2018 ibobei. All rights reserved.
//

#import "WMScrollView+ScrollBack.h"

@implementation WMScrollView (ScrollBack)

#pragma mark - <UIGestureRecognizerDelegate>

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
UIPanGestureRecognizer *tmpGesture = (UIPanGestureRecognizer *)gestureRecognizer;
CGPoint translation = [tmpGesture translationInView:tmpGesture.view];
/* 当scrollView滑到初始位置时,再滑动就让返回手势生效
* translation.x > 0 表示向右滑动 translation.x <= 0 表示向左滑动
*/
if (self.contentOffset.x <= 0
&& translation.x > 0) {
return NO;
}
}

return YES;
}

@end