Last active
March 28, 2020 02:52
-
-
Save fcaldarelli/5bd88d2bf833b213d824506eb1758056 to your computer and use it in GitHub Desktop.
UIAlertController centered in iPad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIPopoverPresentationController *popPresenter = ac.popoverPresentationController; | |
popPresenter.sourceView = self.view; | |
popPresenter.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds),0,0); | |
popPresenter.permittedArrowDirections = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let popPresenter = ac.popoverPresentationController | |
popPresenter?.sourceView = view | |
popPresenter?.sourceRect = CGRect(x: view.bounds.midX, y: view.bounds.midY, width: 0, height: 0) | |
popPresenter?.permittedArrowDirections = [] | |
// Update 28/03/2020 | |
if UIDevice.current.userInterfaceIdiom == .pad { | |
alertController.popoverPresentationController?.sourceView = sourceView | |
alertController.popoverPresentationController?.sourceRect = sourceView.bounds | |
alertController.popoverPresentationController?.permittedArrowDirections = [.down, .up] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment