Swift: hitTest for UIView underneath another UIView

后端 未结 4 1491
闹比i
闹比i 2021-01-06 08:48

I have TransparentUIView on top of RedOrGreenUIView. TransparentUIView has a UILongPressGestureRecognizer attached to it. Once user begins a long touch on it, I check for .C

4条回答
  •  再見小時候
    2021-01-06 09:09

    Swift 4 version :

     override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
            for subview in YourView.subviews as [UIView] {
    
                if !subview.isHidden && subview.alpha > 0 && subview.isUserInteractionEnabled && subview.point(inside:point, with: event) {
                    return true
                }
            }
    
        return false
     }
    

提交回复
热议问题