码迷,mamicode.com
首页 > 移动开发 > 详细

IOS第15天(2,事件处理hitTest练习)

时间:2015-08-31 17:11:08      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:

***hitTest 获取最合适的点

@implementation HMGreenView


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"%s",__func__);
}

//   获取 最合适的 点的view 
//- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
//{
//    // 把自己的点转换按钮的坐标系上的点
//    CGPoint buttonPoint = [self convertPoint:point toView:_button];
//    
//    if ([_button pointInside:buttonPoint withEvent:event]) return nil;  //自己 不是 最合适的点
//
//    
//    return [super hitTest:point withEvent:event];
//}

//  判断是不是最合适的点
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
    // 把左边控件上的点转换为右边上边控件的点
//    CGPoint buttonPoint = [self convertPoint:point toView:_button];
    
    // 从右边这个view上的点转换为坐标上的点
    CGPoint buttonPoint =[_button convertPoint:point fromView:self];
    if ([_button pointInside:buttonPoint withEvent:event]) return NO;    //自己不是最合适的点
    
    
    return [super pointInside:point withEvent:event];
}


@end

 

IOS第15天(2,事件处理hitTest练习)

标签:

原文地址:http://www.cnblogs.com/ios-g/p/4773175.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!