美文网首页
按钮超过父视图范围无法响应事件的处理方法

按钮超过父视图范围无法响应事件的处理方法

作者: EnjoyWT | 来源:发表于2022-11-30 10:32 被阅读0次
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {  
    UIView *view = [super hitTest:point withEvent:event];  
    if (view == nil) {  
    CGPoint tempoint = [btn convertPoint:point fromView:self];  
        if (CGRectContainsPoint(btn.bounds, tempoint))   
    {  
           view = btn;  
        }  
     }             
    return view;  
}  
   override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        var v = super.hitTest(point, with: event)
        if v == nil {
            let tempPoint = self.imageV.convert(point, from: self)
            if self.imageV.bounds.contains(tempPoint){
                v = self.imageV
            }
        }
        return v
    }

相关文章

网友评论

      本文标题:按钮超过父视图范围无法响应事件的处理方法

      本文链接:https://www.haomeiwen.com/subject/rbkdfdtx.html