【发布时间】:2014-12-30 17:47:15
【问题描述】:
我想在用户点击屏幕时添加多个 UIView,我正在使用下面的代码,当我点击时它会创建一个 UIView,但会删除前一个。 我做错了什么?
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
let touch = touches.anyObject()! as UITouch
let location = touch.locationInView(self.view)
println(location)
rectangle.frame = CGRectMake(location.x, location.y, 20, 20)
rectangle.backgroundColor = UIColor.redColor()
self.view.addSubview(rectangle)
}
【问题讨论】:
标签: swift uiview touchesbegan