【发布时间】:2015-09-28 11:27:33
【问题描述】:
按下时如何移动按钮?
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
if let touch = touches.first {
location = touch.locationInView(self.view)
Button.center = location
}
super.touchesBegan(touches, withEvent:event)
}
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
if let touch = touches.first {
location = touch.locationInView(self.view)
Button.center = location
}
super.touchesMoved(touches, withEvent:event)
}
按钮不动。
【问题讨论】: