touchesBegan:获取点的坐标 包含 范围


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    //获取点击点的坐标
    CGPoint touchPoint = [[touches  anyObject] locationInView:self];
    //空白处的范围
    CGRect rect = CGRectMake(0, 0, kWidth, kHeight - 220);
    
    //判断 点(CGPoint)是否在某个范围(CGRect)内
    if (CGRectContainsPoint(rect, touchPoint)) {
        [self dismissSelf];
    }
}

你可能感兴趣的:(touchesBegan:获取点的坐标 包含 范围)