mardi 14 juin 2016

Draggable label - ios


I have a requirement to move a label around only when the user touches on it and drags. I cant find out whether the user touched that label or not. I have used the touchesMoved method(Swift 2). Below is my code

override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
    super.touchesBegan(touches as Set<UITouch>, withEvent: event) 
    let touch = touches.first

  if (touch!.view) == (moveLabel as UIView) // moveButton is my label
  {
    location = touch!.locationInView(self.view)
    moveLabel.center = location
  }
}

When I do this, my label is not moving :( someone help me please


Aucun commentaire:

Enregistrer un commentaire