uiviewcontroller – iOS dismiss using transition animator, size changed of the underlying view


enter image description here

I present two vc’s in a row, and when I dismiss the first vc, why does the size of the following view change to full screen

DismissAnimator: UIViewControllerAnimatedTransitioning {
    
    func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
        guard let fromVc = transitionContext.viewController(forKey: .from),
        let toVc = transitionContext.viewController(forKey: .to) else {
            return
        }
        let containerView = transitionContext.containerView
        containerView.backgroundColor = UIColor.white
        containerView.addSubview(toVc.view)
        containerView.addSubview(fromVc.view)
        
        var y = 200
        var height: CGFloat = UIScreen.main.bounds.size.height - y
        
        UIView.animate(withDuration: transitionDuration(using: transitionContext),
                       animations: {
            self.maskView.alpha = 0
            fromVc.view.frame = CGRect(x: 0, y: UIScreen.main.bounds.size.height, width: UIScreen.main.bounds.size.width, height: height)
        }) { finished in
            transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
        }
    }
}
        let vc = ViewController()
        vc.modalPresentationStyle = .fullScreen
        vc.transitioningDelegate = self
        self.present(vc, animated: true)

The first vc disappears and the second vc’s view size does not change

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img