Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 迅速用手轻扫,顺利解雇_Ios_Swift_Swipe_Dismiss - Fatal编程技术网

Ios 迅速用手轻扫,顺利解雇

Ios 迅速用手轻扫,顺利解雇,ios,swift,swipe,dismiss,Ios,Swift,Swipe,Dismiss,嗨,我使用SwipeGesture在用户向下滑动视图时关闭视图。 我想在使用平滑向下滑动时消除视图。 当用户向下滑动时,我编写以下代码;它会自动工作,但我不想在此时忽略该视图 @objc func respondToSwipeGesture(gesture: UIGestureRecognizer){ func closeOptionsPanel(){ DispatchQueue.main.async(execute: {

嗨,我使用SwipeGesture在用户向下滑动视图时关闭视图。 我想在使用平滑向下滑动时消除视图。 当用户向下滑动时,我编写以下代码;它会自动工作,但我不想在此时忽略该视图

 @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
            }
        }
    }

只需从case UISweepGestureRecognizer.Direction.down中删除该行: self.dismission(动画:true,完成:nil)并将其写在函数末尾

 @objc func respondToSwipeGesture(gesture: UIGestureRecognizer){
     func closeOptionsPanel(){

        DispatchQueue.main.async(execute: {
           let transition: CATransition = CATransition()
    let transition: CATransition = CATransition()
    transition.duration = 0.5
    transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
    transition.type = CATransitionType.reveal
    transition.subtype = CATransitionSubtype.fromRight
    self.view.window!.layer.add(transition, forKey: nil)
    self.dismiss(animated: false, completion: nil)
   })
    }

    if let swipeGesture = gesture as? UISwipeGestureRecognizer {


        switch swipeGesture.direction {
        case UISwipeGestureRecognizer.Direction.right:
            print("Swiped right")
        case UISwipeGestureRecognizer.Direction.down:

            closeOptionsPanel()
        case UISwipeGestureRecognizer.Direction.left:
            print("Swiped left")
        case UISwipeGestureRecognizer.Direction.up:
            print("Swiped up")
        default:
            break
        }
    }
}

请在func中使用此代码,并根据您的要求更改持续时间

func closeOptionsPanel() {
    self.view1.alpha = 1
    self.view1.isHidden = false
    UIView.animate(withDuration: 1.0, animations: {
        self.view1.alpha = 0
    }, completion: {
        finished in
        self.view1.isHidden = true
    })
}

那你什么时候想解雇我?您的问题不完整或无法详细阐述您的问题,请将您的问题说得更清楚。如果您希望手势本身能够实时推动对视图的否定,您需要编写一个自定义的交互式过渡动画。我想在使用smoothly向下滑动时关闭视图。我不想在向下滑动时关闭视图,但这很顺利