UITapGestureRecognizer *singleTap = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(sigleTappedPickerView:)];
[singleTap setNumberOfTapsRequired:1];
[selfaddGestureRecognizer:singleTap];
singleTap.delegate =self;
- (void)sigleTappedPickerView:(UIGestureRecognizer *)sender
{
//取得所点击的点的坐标
CGPoint point = [senderlocationInView:self];
// 判断该点在不在区域内
if (CGRectContainsPoint(CGRectMake(0,FIXED_PICKER_SELECTED_ORIGNALY,FIXED_PICKER_SELECTED_WIDTH, FIXED_PICKER_SELECTED_HEIGHT), point))
{
/ Do what you want
}
}
)
UITouch类中包含如下成员函数:
- (CGPoint)locationInView:(UIView *)view:函数返回一个CGPoint类型的值,表示触摸在view这个视图上的位置,这里返回的位置是针对view的坐标系的。调用时传入的view参数为空的话,返回的时触摸点在整个窗口的位置。
CGRectContainsPoint :一个点是否包含在矩形中