Passing through touches to UIViews underneath

前端 未结 5 1377
庸人自扰
庸人自扰 2020-12-01 03:17

I have a UIView with 4 buttons on it and another UIView on top of the buttons view. The top most view contains a UIImageView with a <

5条回答
  •  旧时难觅i
    2020-12-01 03:49

    @Magic Bullet Dave's solution but in Swift

    Swift 3

    override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
        var pointInside = false
        if commentTextField.frame.contains(point) {
            pointInside = true
        } else {
            commentTextField.resignFirstResponder()
        }
        return pointInside
    }
    

    I use it in my CameraOverlayView for ImagePickerViewController.cameraOverlay to give user ability to comment while taking new photo

提交回复
热议问题