給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