-1

I am creating custom scrollable tabbar using container view i used swipe gesture fo scrolling on swipe i want to do animation on swipe i used UIview.Animate but i can't get animation effect let me show you my code

 @objc func respondToSwipeGesture(gesture: UIGestureRecognizer) {
        if let swipeGesture = gesture as? UISwipeGestureRecognizer {
            switch swipeGesture.direction {
            case UISwipeGestureRecognizer.Direction.right:
                print("Swiped right")
                UIView.animate(withDuration: 0.3) {
                    self.viewG1.isHidden = false
                    self.viewG2.isHidden = false

                    self.viewC1.isHidden = true
                    self.viewC2.isHidden = true

                    self.secondContainView.isHidden = true
                    self.firstContainewView.isHidden = false

                }
            case UISwipeGestureRecognizer.Direction.left:
                print("Swiped left")
                UIView.animate(withDuration: 0.3) {
                    self.viewG1.isHidden = true
                    self.viewG2.isHidden = true
                    self.viewC1.isHidden = false
                    self.viewC2.isHidden = false
                    self.firstContainewView.isHidden = true
                    self.secondContainView.isHidden = false
                }
            default:
                break
            }
        }
    }

In viewDidLoad() i write this code

  let swipe = UISwipeGestureRecognizer(target: self, action: #selector(respondToSwipeGesture(gesture:)))
        swipe.direction = UISwipeGestureRecognizer.Direction.right
        self.view.addGestureRecognizer(swipe)

can any one please tell me how to do swipe animation or where i am done wrong

Vishal
  • 23
  • 6

1 Answers1

0

isHidden property of UIView is not animatable. Use alpha property to get the fade in/out effect.

Ratul Sharker
  • 7,484
  • 4
  • 35
  • 44