I made a custom view to be displayed as popup / custom alert view in the center of the screen. My code displays the view on top of the screen and also the background turns black.
I would like to display the view on the center of the screen and show the controller that presented the view in the background.
I tried changing presentation style to popover and pagesheet, but that covered entire screen. How do I show the view in center with app in background?
Below is the code:
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let customAlert = storyBoard.instantiateViewController(withIdentifier: "CustomAlertViewController") as! CustomAlertViewController
customAlert.providesPresentationContextTransitionStyle = true
customAlert.definesPresentationContext = true
customAlert.modalPresentationStyle = UIModalPresentationStyle.currentContext
customAlert.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
if let topVC = UIApplication.shared.topMostViewController() {
topVC.present(customAlert, animated: true, completion: nil)
}
Edit: Was able to center the view by changing the constraints.

