Chcę dodać widok podrzędny i usunąć jednym dotknięciem. To jest mój kod:
/ * Aby dodać widok podrzędny * /
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)
/ * Aby usunąć widok podrzędny * /
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")
}
}
Ale usunięcie to nie działa. Ktoś może mi pomóc, proszę? Dzięki!