美文网首页
Swift touchesBegan 点击空白处响应事件

Swift touchesBegan 点击空白处响应事件

作者: _风雨 | 来源:发表于2021-09-15 13:51 被阅读0次

Swift touchesBegan 点击空白处响应事件

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        
        guard let touch = touches.first else {
            return
        }
        let touchePoint = touch.location(in: self)
        //判断是否点击到了不包含的view
        if animateContainerView.frame.contains(touchePoint) {
            
        } else {
            dismiss()
        }
    }

相关文章

网友评论

      本文标题:Swift touchesBegan 点击空白处响应事件

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