Reputation: 1635
I'm trying to allow the user to draw a UITextView around the screen like in the SnapChat app. I tried the code below but it doesn't seem to work. Any suggestions? I don't thin the detectPan method is being called. Do I have to override some UITextFieldDelegate property?
var panRecognizer = UIPanGestureRecognizer(target:self, action:"detectPan:")
text.addGestureRecognizer(panRecognizer)
func detectPan(sender:UIPanGestureRecognizer) {
self.view.bringSubviewToFront(sender.view!)
var translation = sender.translationInView(self.view)
sender.view!.center = CGPointMake(sender.view!.center.x + translation.x, sender.view!.center.y + translation.y)
sender.setTranslation(CGPointZero, inView: self.view)
}
Upvotes: 1
Views: 395
Reputation: 1635
Not sure if this is the most efficient way to go about this but I put the textview in a view and disabled user interactions. Then made a tap gesture (which makes the textview the first responder) and pan gesture (which moves the view).
Upvotes: 1