Я хочу добавить sub view и удалить одним нажатием. Это мой код:
/* Чтобы добавить subview */
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)
/* Чтобы удалить subview */
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")
}
}
Но удалить это не работает Кто-нибудь может мне помочь? Спасибо!