Swift/UIViewController

[SWIFT]중첩된 ViewControll 한번에 Dismiss 하기

삽질중 2023. 6. 8. 17:53
func viewContollerAllDismiss(dismissComplete: @escaping ()->Void) {
        var initialPresentingViewController = self.viewController?.presentingViewController
        while let previousPresentingViewController = initialPresentingViewController?.presentingViewController {
            initialPresentingViewController = previousPresentingViewController
        }
        
        if let snapshot = self.snapshotView(afterScreenUpdates: true) {
            initialPresentingViewController?.presentedViewController?.view.addSubview(snapshot)
        }
        
        initialPresentingViewController?.dismiss(animated: true, completion: {
            dismissComplete()
        })
 }