Xcode / Swift | Use UIViewController transition for UINavigationController











up vote
0
down vote

favorite












Storyboard cutting



The steps that I did were:




  1. Create the + and x buttons in the Controllers

  2. Create simple outlets in the Controllers


  3. Create an action in the Controller for the x (dismiss)-button



    @IBAction func button_close_pressed(_ sender: Any) {
    self.dismiss(animated: true, completion: nil)
    }



  4. Create a segue on the Storyboard from the + button to the targetViewController.



  5. Create the transition class.



    import UIKit

    class CircularTransition: NSObject {
    var circle = UIView()
    var startingPoint = CGPoint.zero {
    didSet {
    circle.center = startingPoint
    }
    }
    var circleColor = UIColor.red
    var duration = 3.0
    enum CircularTransitionMode: Int {
    case present, dismiss, pop
    }
    var transitionMode: CircularTransitionMode = .present
    }

    extension CircularTransition: UIViewControllerAnimatedTransitioning {
    func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
    return duration
    }

    func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
    let containerView = transitionContext.containerView
    if transitionMode == .present {
    if let presentedView = transitionContext.view(forKey: UITransitionContextViewKey.to) {
    let viewCenter = presentedView.center
    let viewSize = presentedView.frame.size
    circle = UIView()
    circle.frame = frameForCircle(withViewCenter: viewCenter, size: viewSize, startPoint: startingPoint)
    circle.layer.cornerRadius = circle.frame.size.height / 2
    circle.center = startingPoint
    circle.backgroundColor = circleColor
    circle.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
    containerView.addSubview(circle)
    presentedView.center = startingPoint
    presentedView.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
    presentedView.alpha = 0
    containerView.addSubview(presentedView)
    UIView.animate(withDuration: duration, animations: {
    self.circle.transform = CGAffineTransform.identity
    presentedView.transform = CGAffineTransform.identity
    presentedView.alpha = 1
    presentedView.center = viewCenter
    }, completion: { (success: Bool) in
    transitionContext.completeTransition(success)
    })
    }
    } else {
    let transitionModeKey = (transitionMode == .pop) ? UITransitionContextViewKey.to : UITransitionContextViewKey.from
    if let returningView = transitionContext.view(forKey: transitionModeKey) {
    let viewCenter = returningView.center
    let viewSize = returningView.frame.size
    circle.frame = frameForCircle(withViewCenter: viewCenter, size: viewSize, startPoint: startingPoint)
    circle.layer.cornerRadius = circle.frame.size.height / 2
    circle.center = startingPoint
    UIView.animate(withDuration: duration, animations: {
    self.circle.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
    returningView.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
    returningView.center = self.startingPoint
    returningView.alpha = 0
    if self.transitionMode == .pop {
    containerView.insertSubview(returningView, belowSubview: returningView)
    containerView.insertSubview(self.circle, belowSubview: returningView)
    }
    }, completion: { (success: Bool) in
    returningView.center = viewCenter
    returningView.removeFromSuperview()
    self.circle.removeFromSuperview()
    transitionContext.completeTransition(success)
    })
    }
    }
    }



    func frameForCircle(withViewCenter viewCenter: CGPoint, size viewSize: CGSize, startPoint: CGPoint) -> CGRect {
    let xLength = fmax(startPoint.x, viewSize.width - startPoint.x)
    let yLength = fmax(startPoint.y, viewSize.height - startPoint.y)
    let offsetVector = sqrt(xLength * xLength + yLength * yLength) * 2
    let size = CGSize(width: offsetVector, height: offsetVector)
    return CGRect(origin: CGPoint.zero, size: size)
    }
    }



  6. In the source Controller I added ... to the class



    UIViewControllerTransitioningDelegate



  7. Then



    let transition = CircularTransition()



  8. And last but not least



    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    let eventVC = segue.destination as! EventViewController
    eventVC.transitioningDelegate = self
    eventVC.modalPresentationStyle = .custom
    }

    func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    transition.transitionMode = .present
    transition.startingPoint = self.button_addEvent.center
    transition.circleColor = self.button_addEvent.backgroundColor!
    return transition
    }

    func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    transition.transitionMode = .dismiss
    transition.startingPoint = self.button_addEvent.center
    transition.circleColor = self.button_addEvent.backgroundColor!
    return transition
    }



Now, why doesn't that work? I only can think of that the problem comes with the Navigation Controller instead of a normal ViewController, because with a normal one it works fine. But I really have no idea hwo to change the code to match with the Navigation Controller (source Controller).
Kind regards and thank you!










share|improve this question




























    up vote
    0
    down vote

    favorite












    Storyboard cutting



    The steps that I did were:




    1. Create the + and x buttons in the Controllers

    2. Create simple outlets in the Controllers


    3. Create an action in the Controller for the x (dismiss)-button



      @IBAction func button_close_pressed(_ sender: Any) {
      self.dismiss(animated: true, completion: nil)
      }



    4. Create a segue on the Storyboard from the + button to the targetViewController.



    5. Create the transition class.



      import UIKit

      class CircularTransition: NSObject {
      var circle = UIView()
      var startingPoint = CGPoint.zero {
      didSet {
      circle.center = startingPoint
      }
      }
      var circleColor = UIColor.red
      var duration = 3.0
      enum CircularTransitionMode: Int {
      case present, dismiss, pop
      }
      var transitionMode: CircularTransitionMode = .present
      }

      extension CircularTransition: UIViewControllerAnimatedTransitioning {
      func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
      return duration
      }

      func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
      let containerView = transitionContext.containerView
      if transitionMode == .present {
      if let presentedView = transitionContext.view(forKey: UITransitionContextViewKey.to) {
      let viewCenter = presentedView.center
      let viewSize = presentedView.frame.size
      circle = UIView()
      circle.frame = frameForCircle(withViewCenter: viewCenter, size: viewSize, startPoint: startingPoint)
      circle.layer.cornerRadius = circle.frame.size.height / 2
      circle.center = startingPoint
      circle.backgroundColor = circleColor
      circle.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
      containerView.addSubview(circle)
      presentedView.center = startingPoint
      presentedView.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
      presentedView.alpha = 0
      containerView.addSubview(presentedView)
      UIView.animate(withDuration: duration, animations: {
      self.circle.transform = CGAffineTransform.identity
      presentedView.transform = CGAffineTransform.identity
      presentedView.alpha = 1
      presentedView.center = viewCenter
      }, completion: { (success: Bool) in
      transitionContext.completeTransition(success)
      })
      }
      } else {
      let transitionModeKey = (transitionMode == .pop) ? UITransitionContextViewKey.to : UITransitionContextViewKey.from
      if let returningView = transitionContext.view(forKey: transitionModeKey) {
      let viewCenter = returningView.center
      let viewSize = returningView.frame.size
      circle.frame = frameForCircle(withViewCenter: viewCenter, size: viewSize, startPoint: startingPoint)
      circle.layer.cornerRadius = circle.frame.size.height / 2
      circle.center = startingPoint
      UIView.animate(withDuration: duration, animations: {
      self.circle.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
      returningView.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
      returningView.center = self.startingPoint
      returningView.alpha = 0
      if self.transitionMode == .pop {
      containerView.insertSubview(returningView, belowSubview: returningView)
      containerView.insertSubview(self.circle, belowSubview: returningView)
      }
      }, completion: { (success: Bool) in
      returningView.center = viewCenter
      returningView.removeFromSuperview()
      self.circle.removeFromSuperview()
      transitionContext.completeTransition(success)
      })
      }
      }
      }



      func frameForCircle(withViewCenter viewCenter: CGPoint, size viewSize: CGSize, startPoint: CGPoint) -> CGRect {
      let xLength = fmax(startPoint.x, viewSize.width - startPoint.x)
      let yLength = fmax(startPoint.y, viewSize.height - startPoint.y)
      let offsetVector = sqrt(xLength * xLength + yLength * yLength) * 2
      let size = CGSize(width: offsetVector, height: offsetVector)
      return CGRect(origin: CGPoint.zero, size: size)
      }
      }



    6. In the source Controller I added ... to the class



      UIViewControllerTransitioningDelegate



    7. Then



      let transition = CircularTransition()



    8. And last but not least



      override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
      let eventVC = segue.destination as! EventViewController
      eventVC.transitioningDelegate = self
      eventVC.modalPresentationStyle = .custom
      }

      func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
      transition.transitionMode = .present
      transition.startingPoint = self.button_addEvent.center
      transition.circleColor = self.button_addEvent.backgroundColor!
      return transition
      }

      func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
      transition.transitionMode = .dismiss
      transition.startingPoint = self.button_addEvent.center
      transition.circleColor = self.button_addEvent.backgroundColor!
      return transition
      }



    Now, why doesn't that work? I only can think of that the problem comes with the Navigation Controller instead of a normal ViewController, because with a normal one it works fine. But I really have no idea hwo to change the code to match with the Navigation Controller (source Controller).
    Kind regards and thank you!










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Storyboard cutting



      The steps that I did were:




      1. Create the + and x buttons in the Controllers

      2. Create simple outlets in the Controllers


      3. Create an action in the Controller for the x (dismiss)-button



        @IBAction func button_close_pressed(_ sender: Any) {
        self.dismiss(animated: true, completion: nil)
        }



      4. Create a segue on the Storyboard from the + button to the targetViewController.



      5. Create the transition class.



        import UIKit

        class CircularTransition: NSObject {
        var circle = UIView()
        var startingPoint = CGPoint.zero {
        didSet {
        circle.center = startingPoint
        }
        }
        var circleColor = UIColor.red
        var duration = 3.0
        enum CircularTransitionMode: Int {
        case present, dismiss, pop
        }
        var transitionMode: CircularTransitionMode = .present
        }

        extension CircularTransition: UIViewControllerAnimatedTransitioning {
        func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
        return duration
        }

        func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
        let containerView = transitionContext.containerView
        if transitionMode == .present {
        if let presentedView = transitionContext.view(forKey: UITransitionContextViewKey.to) {
        let viewCenter = presentedView.center
        let viewSize = presentedView.frame.size
        circle = UIView()
        circle.frame = frameForCircle(withViewCenter: viewCenter, size: viewSize, startPoint: startingPoint)
        circle.layer.cornerRadius = circle.frame.size.height / 2
        circle.center = startingPoint
        circle.backgroundColor = circleColor
        circle.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
        containerView.addSubview(circle)
        presentedView.center = startingPoint
        presentedView.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
        presentedView.alpha = 0
        containerView.addSubview(presentedView)
        UIView.animate(withDuration: duration, animations: {
        self.circle.transform = CGAffineTransform.identity
        presentedView.transform = CGAffineTransform.identity
        presentedView.alpha = 1
        presentedView.center = viewCenter
        }, completion: { (success: Bool) in
        transitionContext.completeTransition(success)
        })
        }
        } else {
        let transitionModeKey = (transitionMode == .pop) ? UITransitionContextViewKey.to : UITransitionContextViewKey.from
        if let returningView = transitionContext.view(forKey: transitionModeKey) {
        let viewCenter = returningView.center
        let viewSize = returningView.frame.size
        circle.frame = frameForCircle(withViewCenter: viewCenter, size: viewSize, startPoint: startingPoint)
        circle.layer.cornerRadius = circle.frame.size.height / 2
        circle.center = startingPoint
        UIView.animate(withDuration: duration, animations: {
        self.circle.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
        returningView.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
        returningView.center = self.startingPoint
        returningView.alpha = 0
        if self.transitionMode == .pop {
        containerView.insertSubview(returningView, belowSubview: returningView)
        containerView.insertSubview(self.circle, belowSubview: returningView)
        }
        }, completion: { (success: Bool) in
        returningView.center = viewCenter
        returningView.removeFromSuperview()
        self.circle.removeFromSuperview()
        transitionContext.completeTransition(success)
        })
        }
        }
        }



        func frameForCircle(withViewCenter viewCenter: CGPoint, size viewSize: CGSize, startPoint: CGPoint) -> CGRect {
        let xLength = fmax(startPoint.x, viewSize.width - startPoint.x)
        let yLength = fmax(startPoint.y, viewSize.height - startPoint.y)
        let offsetVector = sqrt(xLength * xLength + yLength * yLength) * 2
        let size = CGSize(width: offsetVector, height: offsetVector)
        return CGRect(origin: CGPoint.zero, size: size)
        }
        }



      6. In the source Controller I added ... to the class



        UIViewControllerTransitioningDelegate



      7. Then



        let transition = CircularTransition()



      8. And last but not least



        override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        let eventVC = segue.destination as! EventViewController
        eventVC.transitioningDelegate = self
        eventVC.modalPresentationStyle = .custom
        }

        func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        transition.transitionMode = .present
        transition.startingPoint = self.button_addEvent.center
        transition.circleColor = self.button_addEvent.backgroundColor!
        return transition
        }

        func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        transition.transitionMode = .dismiss
        transition.startingPoint = self.button_addEvent.center
        transition.circleColor = self.button_addEvent.backgroundColor!
        return transition
        }



      Now, why doesn't that work? I only can think of that the problem comes with the Navigation Controller instead of a normal ViewController, because with a normal one it works fine. But I really have no idea hwo to change the code to match with the Navigation Controller (source Controller).
      Kind regards and thank you!










      share|improve this question















      Storyboard cutting



      The steps that I did were:




      1. Create the + and x buttons in the Controllers

      2. Create simple outlets in the Controllers


      3. Create an action in the Controller for the x (dismiss)-button



        @IBAction func button_close_pressed(_ sender: Any) {
        self.dismiss(animated: true, completion: nil)
        }



      4. Create a segue on the Storyboard from the + button to the targetViewController.



      5. Create the transition class.



        import UIKit

        class CircularTransition: NSObject {
        var circle = UIView()
        var startingPoint = CGPoint.zero {
        didSet {
        circle.center = startingPoint
        }
        }
        var circleColor = UIColor.red
        var duration = 3.0
        enum CircularTransitionMode: Int {
        case present, dismiss, pop
        }
        var transitionMode: CircularTransitionMode = .present
        }

        extension CircularTransition: UIViewControllerAnimatedTransitioning {
        func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
        return duration
        }

        func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
        let containerView = transitionContext.containerView
        if transitionMode == .present {
        if let presentedView = transitionContext.view(forKey: UITransitionContextViewKey.to) {
        let viewCenter = presentedView.center
        let viewSize = presentedView.frame.size
        circle = UIView()
        circle.frame = frameForCircle(withViewCenter: viewCenter, size: viewSize, startPoint: startingPoint)
        circle.layer.cornerRadius = circle.frame.size.height / 2
        circle.center = startingPoint
        circle.backgroundColor = circleColor
        circle.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
        containerView.addSubview(circle)
        presentedView.center = startingPoint
        presentedView.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
        presentedView.alpha = 0
        containerView.addSubview(presentedView)
        UIView.animate(withDuration: duration, animations: {
        self.circle.transform = CGAffineTransform.identity
        presentedView.transform = CGAffineTransform.identity
        presentedView.alpha = 1
        presentedView.center = viewCenter
        }, completion: { (success: Bool) in
        transitionContext.completeTransition(success)
        })
        }
        } else {
        let transitionModeKey = (transitionMode == .pop) ? UITransitionContextViewKey.to : UITransitionContextViewKey.from
        if let returningView = transitionContext.view(forKey: transitionModeKey) {
        let viewCenter = returningView.center
        let viewSize = returningView.frame.size
        circle.frame = frameForCircle(withViewCenter: viewCenter, size: viewSize, startPoint: startingPoint)
        circle.layer.cornerRadius = circle.frame.size.height / 2
        circle.center = startingPoint
        UIView.animate(withDuration: duration, animations: {
        self.circle.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
        returningView.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)
        returningView.center = self.startingPoint
        returningView.alpha = 0
        if self.transitionMode == .pop {
        containerView.insertSubview(returningView, belowSubview: returningView)
        containerView.insertSubview(self.circle, belowSubview: returningView)
        }
        }, completion: { (success: Bool) in
        returningView.center = viewCenter
        returningView.removeFromSuperview()
        self.circle.removeFromSuperview()
        transitionContext.completeTransition(success)
        })
        }
        }
        }



        func frameForCircle(withViewCenter viewCenter: CGPoint, size viewSize: CGSize, startPoint: CGPoint) -> CGRect {
        let xLength = fmax(startPoint.x, viewSize.width - startPoint.x)
        let yLength = fmax(startPoint.y, viewSize.height - startPoint.y)
        let offsetVector = sqrt(xLength * xLength + yLength * yLength) * 2
        let size = CGSize(width: offsetVector, height: offsetVector)
        return CGRect(origin: CGPoint.zero, size: size)
        }
        }



      6. In the source Controller I added ... to the class



        UIViewControllerTransitioningDelegate



      7. Then



        let transition = CircularTransition()



      8. And last but not least



        override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        let eventVC = segue.destination as! EventViewController
        eventVC.transitioningDelegate = self
        eventVC.modalPresentationStyle = .custom
        }

        func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        transition.transitionMode = .present
        transition.startingPoint = self.button_addEvent.center
        transition.circleColor = self.button_addEvent.backgroundColor!
        return transition
        }

        func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        transition.transitionMode = .dismiss
        transition.startingPoint = self.button_addEvent.center
        transition.circleColor = self.button_addEvent.backgroundColor!
        return transition
        }



      Now, why doesn't that work? I only can think of that the problem comes with the Navigation Controller instead of a normal ViewController, because with a normal one it works fine. But I really have no idea hwo to change the code to match with the Navigation Controller (source Controller).
      Kind regards and thank you!







      swift xcode






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 at 11:47









      MuhammadBassio

      1,364812




      1,364812










      asked Nov 19 at 7:18









      F. Leeser

      14




      14
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          You need to implement UINavigationControllerDelegate in your viewController



          func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
          switch operation {
          case .push:
          transition.transitionMode = .present
          transition.startingPoint = self.button_addEvent.center
          transition.circleColor = self.button_addEvent.backgroundColor!
          return transition
          default:
          transition.transitionMode = .dismiss
          transition.startingPoint = self.button_addEvent.center
          transition.circleColor = self.button_addEvent.backgroundColor!
          return transition
          }
          }





          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369936%2fxcode-swift-use-uiviewcontroller-transition-for-uinavigationcontroller%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            You need to implement UINavigationControllerDelegate in your viewController



            func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
            switch operation {
            case .push:
            transition.transitionMode = .present
            transition.startingPoint = self.button_addEvent.center
            transition.circleColor = self.button_addEvent.backgroundColor!
            return transition
            default:
            transition.transitionMode = .dismiss
            transition.startingPoint = self.button_addEvent.center
            transition.circleColor = self.button_addEvent.backgroundColor!
            return transition
            }
            }





            share|improve this answer

























              up vote
              0
              down vote



              accepted










              You need to implement UINavigationControllerDelegate in your viewController



              func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
              switch operation {
              case .push:
              transition.transitionMode = .present
              transition.startingPoint = self.button_addEvent.center
              transition.circleColor = self.button_addEvent.backgroundColor!
              return transition
              default:
              transition.transitionMode = .dismiss
              transition.startingPoint = self.button_addEvent.center
              transition.circleColor = self.button_addEvent.backgroundColor!
              return transition
              }
              }





              share|improve this answer























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                You need to implement UINavigationControllerDelegate in your viewController



                func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
                switch operation {
                case .push:
                transition.transitionMode = .present
                transition.startingPoint = self.button_addEvent.center
                transition.circleColor = self.button_addEvent.backgroundColor!
                return transition
                default:
                transition.transitionMode = .dismiss
                transition.startingPoint = self.button_addEvent.center
                transition.circleColor = self.button_addEvent.backgroundColor!
                return transition
                }
                }





                share|improve this answer












                You need to implement UINavigationControllerDelegate in your viewController



                func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
                switch operation {
                case .push:
                transition.transitionMode = .present
                transition.startingPoint = self.button_addEvent.center
                transition.circleColor = self.button_addEvent.backgroundColor!
                return transition
                default:
                transition.transitionMode = .dismiss
                transition.startingPoint = self.button_addEvent.center
                transition.circleColor = self.button_addEvent.backgroundColor!
                return transition
                }
                }






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 19 at 11:16









                MuhammadBassio

                1,364812




                1,364812






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369936%2fxcode-swift-use-uiviewcontroller-transition-for-uinavigationcontroller%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Costa Masnaga

                    Fotorealismo

                    Sidney Franklin