我想添加子视图和删除一个点击。 这是我的暗号:
添加子视图:
var testView: UIView = UIView(frame: CGRectMake(0, 0, 320, 568))
testView.backgroundColor = UIColor.blueColor()
testView.alpha = 0.5
testView.tag = 100
super.view.userInteractionEnabled = false
self.view.userInteractionEnabled = true
self.view.addSubview(testView)
删除子视野:
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
let touch = touches.anyObject() as UITouch
let point = touch.locationInView(self.view)
if(testView.tag==100){
println("Tag 100")
testView.removeFromSuperview()
}
else{
println("tag not found")
}
}
但是移除它不起作用