탭 한 번으로 하위보기를 추가하고 제거하고 싶습니다. 이것은 내 코드입니다.
/ * 하위보기를 추가하려면 * /
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")
}
}
그러나 제거가 작동하지 않습니다 누군가가 나를 도울 수 있습니까? 감사!