UIPanGestureRecognizer with fade animation

So, I have a uiview inside my UIViewController. It looks something like this ... enter image description here

What I am trying to do with UIPanGestureRecognizer, when I scroll to the right or left (starting from any green line in the image and ending with another green line), the red view disappears, but with a fade out animation.

Here's what I've tried ...

let gestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handlePan(gestureRecognizer:)))
    myview.addGestureRecognizer(gestureRecognizer)

func handlePan(gestureRecognizer: UIPanGestureRecognizer) {

    if gestureRecognizer.state == .began {
        UIView.animate(withDuration: 0.5, delay: 0.5, options: UIViewAnimationOptions.curveEaseOut, animations: {
            //maybe this code works.??
        }, completion: nil)
    }

    if gestureRecognizer.state == .changed {
        let translation = gestureRecognizer.translation(in: self.view)
        //something with translation .x and .y values??
    }
}

      

But I'm not sure how to achieve my goal. If you can help me ... Thanks!

+3
ios swift uipangesturerecognizer


source to share


No one has answered this question yet

Check out similar questions:

909
How do I change restrictions changes?
thirty
UIView animation based on UIPanGestureRecognizer speed
3
Custom transition in Swift 3 does not translate correctly
1
Problems with casting cell types to remove
1
Swift 2 iOS 9 animation disappears after changing button text
1
UIPanGestureRecognizer doesn't work when i zoom in
1
Strange animation occurs when expanding UIView
0
UIScrollView cannot display image in portrait or landscape mode
0
UIPanGestureRecognizer conflicts with constraint animation
0
Custom TableViewCell conflicts with recently linked cell .xib



All Articles
Loading...
X
Show
Funny
Dev
Pics