1. 程式人生 > >【原】ios的hitTest方法以及不規則區域內觸控事件處理方法

【原】ios的hitTest方法以及不規則區域內觸控事件處理方法

 - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
 {
     UIView *hitView = nil;
     //NSLog(@"point:%@", NSStringFromCGPoint(point));
     UIButton *roundBtn = (UIButton *)[self viewWithTag:10086];
     UIButton *leftBtn = (UIButton *)[self viewWithTag:10087];
     UIButton *rightBtn = (UIButton *)[self viewWithTag:10088];
     BOOL pointInRound = [self touchPointInsideCircle:roundBtn.center radius:30 targetPoint:point];
     if (pointInRound) {
         hitView = roundBtn;
    } else if(CGRectContainsPoint(leftBtn.frame, point)) {
         hitView  = leftBtn;
     } else if(CGRectContainsPoint(rightBtn.frame, point)) {
         hitView = rightBtn;
     } else {
         hitView = self;
     }
     return hitView;
 }