IOS - How to hide a view by touching anywhere outside of it

后端 未结 12 1612
温柔的废话
温柔的废话 2020-12-29 23:23

I\'m new to IOS programming, I\'m displaying a view when a button is clicked, using the following code inside the button method.

 @IBAction func moreButton(_         


        
12条回答
  •  太阳男子
    2020-12-29 23:49

    You can use the below function some this check on the view name will not work but if you have more than one view the problem you will see that if you tap inside your second view the same action will perform. I would prefer to add tapGesture. This is the other solution.

    override func touchesBegan(_ touches: Set, with event: UIEvent?) {
    
    
    }
    

提交回复
热议问题