func infoView() {
let testView: UIView = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 568))
testView.backgroundColor = .gray
testView.alpha = 0.3
testView.tag = 100
testView.isUserInteractionEnabled = true
self.view.addSubview(testView)
let aSelector : Selector = #selector(removeSubview)
let tapGesture = UITapGestureRecognizer(target:self, action: aSelector)
testView.addGestureRecognizer(tapGesture)
}
func removeSubview(){
print("Start remove sibview")
if let viewWithTag = self.view.viewWithTag(100) {
viewWithTag.removeFromSuperview()
}else{
print("No!")
}
}
removeFromSuperview
最新推荐文章于 2021-05-26 15:54:30 发布