Skip to content

Commit

Permalink
fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
anubhavpulkit committed Jul 25, 2020
1 parent a49e775 commit 5592458
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions AmahiAnywhere/AmahiAnywhere/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

populateRegistrationDomain()

UIViewController.setPresentationStyle_fullScreen()

useCastContainerViewController = false

NotificationCenter.default.addObserver(self, selector: #selector(syncWithUserDefaults),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,35 @@ class LoginViewController: BaseUIViewController {

}

extension UIViewController {

@objc private func swizzled_presentstyle(_ viewControllerToPresent: UIViewController, animated: Bool, completion: (() -> Void)?) {

if #available(iOS 13.0, *) {
if viewControllerToPresent.modalPresentationStyle == .automatic || viewControllerToPresent.modalPresentationStyle == .pageSheet {
viewControllerToPresent.modalPresentationStyle = .fullScreen
}
}

self.swizzled_presentstyle(viewControllerToPresent, animated: animated, completion: completion)
}

static func setPresentationStyle_fullScreen() {

let instance: UIViewController = UIViewController()
let aClass: AnyClass! = object_getClass(instance)

let originalSelector = #selector(UIViewController.present(_:animated:completion:))
let swizzledSelector = #selector(UIViewController.swizzled_presentstyle(_:animated:completion:))

let originalMethod = class_getInstanceMethod(aClass, originalSelector)
let swizzledMethod = class_getInstanceMethod(aClass, swizzledSelector)
if let originalMethod = originalMethod, let swizzledMethod = swizzledMethod {
method_exchangeImplementations(originalMethod, swizzledMethod)
}
}
}

// Mark - Login view implementations
extension LoginViewController: LoginView {

Expand Down

0 comments on commit 5592458

Please sign in to comment.