响应事件透过某个视图点击下面的视图

响应时间透过某个视图点击下面的视图:

在上层视图中加入下面的代码

///判断点的区域,在当前视图中的子视图有响应时间就返回响应视图,没有就返回nil,将手势传递到下层视图
///判断手势
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
    {
        if (CGRectContainsPoint(self.meunButton.frame, point)) {
            return self.meunButton;
        }else if (CGRectContainsPoint(self.homeButton.frame, point)){
            return self.homeButton;
        
        }else if (CGRectContainsPoint(self.currentLocation.frame, point)){
            return self.currentLocation;
            
        }else if (CGRectContainsPoint(self.organizationButton.frame, point)){
            return self.organizationButton;
            
        }else if (CGRectContainsPoint(self.activityButton.frame, point)){
            return self.activityButton;
            
        }else if (CGRectContainsPoint(self.positionButton.frame, point)){
            
            return self.positionButton;
        }else if (CGRectContainsPoint(self.workAddress.frame, point)){
            
            return self.workAddress;
        }
        
        return nil;
}
 

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,542评论 25 709
  • 本文翻译自 Thinking Clearly About Performance 这是我三年前读到的一篇关于性能问...
    mindwind阅读 5,048评论 1 8
  • 翻译自“Collection View Programming Guide for iOS” 0 关于iOS集合视...
    lakerszhy阅读 9,325评论 1 22
  • 昨晚收听了小侯爷的《写作也有思考力》,原来写作也要构建框架。用于写作的“金字塔原理”,即提出结论,阐述论点,总结结...
    小自班048明诗阅读 1,566评论 0 1
  • 大美中卫 文||与你相识 用一束花装扮 语言早已失色 那些山山水水的秀丽 如一条彩虹的色彩 长河落日圆的魅力 让多...
    与你相识_40fa阅读 1,293评论 1 3