//加速计事件
//远程控制事件
- (CGPoint)locationInView:(UIView *)view;
- (CGPoint)previousLocationInView:(UIView *)view;
@property(nonatomic,readonly) UIEventType type;
@property(nonatomic,readonly) UIEventSubtype subtype;
@property(nonatomic,readonly) NSTimeInterval timestamp;
touchesBegan…
touchesMoved…
touchedEnded…
// point:是方法调用者坐标系上的触摸点的位置
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
// 1.判断下能否接收触摸事件
if (self.userInteractionEnabled == NO || self.hidden == YES || self.alpha <= 0.0) return nil;
// 2.判断下点在不在控件上
if ([self pointInside:point withEvent:event] == NO) return nil;
// 3.从后往前遍历子控件
int count = (int)self.subviews.count;
for (int i = count - 1; i >= 0 ; i--) {
// 取出显示在最前面的子控件
UIView *childView = self.subviews[i];
// 转换成子控件坐标系上点
CGPoint childP = [self convertPoint:point toView:childView];
UIView *fitView = [childView hitTest:childP withEvent:event];
if (fitView) {
return fitView;
}
}
// 表示没有比自己更合适的view
return self;
}
UIGestureRecognizer是一个抽象类,定义了所有手势的基本行为,使用它的子类才能处理具体的手势
UITapGestureRecognizer(敲击)
UIPinchGestureRecognizer(捏合,用于缩放)
UIPanGestureRecognizer(拖拽)
UISwipeGestureRecognizer(轻扫)
UIRotationGestureRecognizer(旋转)
UILongPressGestureRecognizer(长按)
Demo:https://github.com/SYLing/Gesture.git