Search code examples
iosswiftinterface-builderuiswipegesturerecognizer

Change UISwipeGestureRecognizer direction in Interface Builder


I have a function handleSwipe that is connected to an image view (imageContainer3), so when user swipes the image, an animations happens. Here is the function.

@IBAction func handleSwipe(recognizer:UISwipeGestureRecognizer) {
    self.imageContainer3.center = CGPoint(x:29, y:264)
    UIView.animateWithDuration(1.2, animations: {
        self.imageContainer3.center = CGPoint(x:29, y:157)

    })

}

Problem is that by default this function only triggers when user swipes to the right. I would like it not to recognize right swipe, but left swipe. Do you know how I can achieve desired result in swift ? Tks


Solution

  • If you select the swipe gesture recognizer in your storyboard, you can change the swipe direction in the Attributes Inspector:

    enter image description here