首页 > 移动平台 > 详细

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

时间:2015-08-31 17:10:31      阅读:264      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!