Hi I am using SwipeGesture for dismissing the view when the user swipes down on the view. I want to dismiss the view at swipe down with smooth. I write the following code for when the user swipes down; it works automatically, but I don't want to dismiss the view at the time.
@objc func respondToSwipeGesture(gesture: UIGestureRecognizer){
func closeOptionsPanel(){
DispatchQueue.main.async(execute: {
let animation = CATransition()
animation.type = kCATransitionReveal
animation.subtype = kCATransitionFromLeft
animation.duration = 1.0
animation.delegate = self as? CAAnimationDelegate
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
})
// UIView.animate(withDuration:10000000) {
// self.view.layoutIfNeeded()
// }
}
if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
case UISwipeGestureRecognizer.Direction.right:
print("Swiped right")
case UISwipeGestureRecognizer.Direction.down:
closeOptionsPanel()
self.dismiss(animated: true, completion: nil)
case UISwipeGestureRecognizer.Direction.left:
print("Swiped left")
case UISwipeGestureRecognizer.Direction.up:
print("Swiped up")
default:
break
}
}
}