zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
//  JYPulleyScrollView.m
//  JYPulleyController
//
//  Created by JunpuChen on 2018/7/30.
//  Copyright © 2018年 earnestLin. All rights reserved.
//
 
#import "JYPulleyScrollView.h"
 
@implementation JYPulleyScrollView
 
#pragma mark - Override
 
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    if ([self.touchDelegate respondsToSelector:@selector(shouldTouchPulleyScrollView:point:)]) {
        if ([self.touchDelegate shouldTouchPulleyScrollView:self point:point]) {
            UIView *view = [self.touchDelegate viewToReceiveTouch:self point:point];
            CGPoint p = [view convertPoint:point fromView:self];
            return [view hitTest:p withEvent:event];
        }
    }
    return [super hitTest:point withEvent:event];
}
 
/// 如果 scrollView 上有 button,优先滚动
- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
    if ([view isKindOfClass:[UIButton class]]) {
        return YES;
    }
    return [super touchesShouldCancelInContentView:view];
}
 
@end