DirectionDismiss is not working
yongxuean opened this issue · 0 comments
yongxuean commented
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
}
}
}