拖动标签时更改文本UIPanGesture到达第一个位置!!斯威夫特,IOS

时间:2016-04-02 21:07:06

标签: ios swift uipangesturerecognizer

我有Label和UIPanGestureRecognizer。拖动到新位置时,我会更改文本,但它会更改并返回默认位置!!

我想更改文字并保持拖动位置

处理代码:

  func handlePanGesture(panGesture: UIPanGestureRecognizer) {

var translation = panGesture.translationInView(view)
panGesture.setTranslation(CGPointZero, inView: view)
println(translation)

label.center = CGPoint(x: label.center.x+translation.x, y: label.center.y+translation.y)
label.multipleTouchEnabled = true
label.userInteractionEnabled = true

if panGesture.state == UIGestureRecognizerState.Ended {

   label.text = "End Drag"

}}

0 个答案:

没有答案