Jelly icon indicating copy to clipboard operation
Jelly copied to clipboard

DirectionDismiss is not working

Open yongxuean opened this issue 2 years ago • 0 comments

I want it to disappear from the left, not from the bottom

class BasePresentationController: UIViewController {

static func presentFromLeftToRight<T: BasePresentationController>(on hostViewController: UIViewController, returnType: T.Type) -> T? {
    let nibName = self.className.replacingOccurrences(of: "ViewController", with: "").replacingOccurrences(of: "Controller", with: "")
    if let presentedVC = UIStoryboard(name: nibName, bundle: nil).instantiateInitialViewController() as? BaseNavigationController {
        guard let vc = presentedVC.viewControllers.first as? T else { return nil }
        let uiConfiguration = PresentationUIConfiguration(backgroundStyle: .dimmed(alpha: 0.7), isTapBackgroundToDismissEnabled: true)
        let alignment = PresentationAlignment(vertical: .center, horizontal: .left)
        let size = PresentationSize(width: .custom(value: 243), height: .fullscreen)
        let presentation = CoverPresentation(directionShow: .left, directionDismiss: .left, uiConfiguration: uiConfiguration, size: size, alignment: alignment)
        let animator = Animator(presentation: presentation)
        animator.prepare(presentedViewController: presentedVC)
        hostViewController.present(presentedVC, animated: true, completion: nil)
        return vc
    } else {
        guard let presentedVC = UIStoryboard(name: nibName, bundle: nil).instantiateInitialViewController() as? T else { return nil }
        let uiConfiguration = PresentationUIConfiguration(backgroundStyle: .dimmed(alpha: 0.7), isTapBackgroundToDismissEnabled: true)
        let alignment = PresentationAlignment(vertical: .center, horizontal: .left)
        let size = PresentationSize(width: .custom(value: 243), height: .fullscreen)
        let presentation = CoverPresentation(directionShow: .left, directionDismiss: .left, uiConfiguration: uiConfiguration, size: size, alignment: alignment)
        let animator = Animator(presentation: presentation)
        animator.prepare(presentedViewController: presentedVC)
        hostViewController.present(presentedVC, animated: true, completion: nil)
        return presentedVC
    }
}

}

yongxuean avatar Aug 11 '21 00:08 yongxuean