给UIScrollView写一个延展
.h文件实现:
@interface UIScrollView (NSFoundation)
@end
.m文件实现
@implementation UIScrollView (ScrollTouch)
//重写touchesBegin方法
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//主要代码实现:
[[self nextResponder] touchesBegan:touches withEvent:event];
//super调用,别漏
[super touchesBegan:touches withEvent:event];
}
//重写touchesEnded方法
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[[self nextResponder] touchesEnded:touches withEvent:event];
[super touchesEnded:touches withEvent:event];
}
//重写touchesMoved方法
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[[self nextResponder] touchesMoved:touches withEvent:event];
[super touchesMoved:touches withEvent:event];
}
@end
时间: 2024-10-28 21:22:30