You can do this by overriding your initialization methods of a subclass of UIViewController like this.
class SomeViewController: UIViewController { required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.modalTransitionStyle = .crossDissolve self.modalPresentationStyle = .overFullScreen } override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) self.modalTransitionStyle = .crossDissolve self.modalPresentationStyle = .overFullScreen }
Then on another UIViewController you can initialize the specified ViewController.
xib and / or programmatically
// instantiate your UIViewController let viewController = SomeViewController() self.present(viewController, animated: true, completion: nil)
storyboard
// instantiate the storyboard containing your UIViewController let storyboard = UIStoryboard(name: "StoryboardName", bundle: nil) // place UIViewController initialization inside if let block to prevent unwanted crashes if let viewController = storyboard.instantiateViewController(withIdentifier: "SomeViewController Identifier") as? SomeViewController { self.present(viewController, animated: true, completion: nil) }
Make sure your view hierarchy looks like this:

These should be their properties.
View
Transparent dark background
- backgroundColor = .black
- alpha = 0.4
Popover view
.. all you want it to be
Zonily jame
source share