import UIKit class ShowTransparentViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .white var cfg = UIButton.Configuration.filled() cfg.title = "Show Transparent VC" let btn = UIButton(configuration: cfg, primaryAction: UIAction() { _ in self.presentTransparentVC() }) btn.translatesAutoresizingMaskIntoConstraints = false view.addSubview(btn) let g = view.safeAreaLayoutGuide NSLayoutConstraint.activate([ btn.topAnchor.constraint(equalTo: g.topAnchor, constant: 60.0), btn.centerXAnchor.constraint(equalTo: view.centerXAnchor), ]) } func presentTransparentVC() { let vc = TransparentViewController() vc.modalPresentationStyle = .overFullScreen // personal choice... I find .crossDissolve nicer for full-screen modals vc.modalTransitionStyle = .crossDissolve present(vc, animated: true, completion: nil) } } class TransparentViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Set background color to black with 50% alpa view.backgroundColor = UIColor.black.withAlphaComponent(0.5) // "bottom" view with rounded corners let bottomView = UIView() bottomView.backgroundColor = .init(red: 0.95, green: 0.95, blue: 0.975, alpha: 1.0) bottomView.layer.cornerRadius = 32.0 // "X" close button var cfg = UIButton.Configuration.plain() cfg.title = "X" let btn = UIButton(configuration: cfg, primaryAction: UIAction() { _ in self.dismiss(animated: true) }) btn.translatesAutoresizingMaskIntoConstraints = false bottomView.addSubview(btn) bottomView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(bottomView) let g = view.safeAreaLayoutGuide NSLayoutConstraint.activate([ bottomView.bottomAnchor.constraint(equalTo: g.bottomAnchor, constant: 40.0), bottomView.leadingAnchor.constraint(equalTo: g.leadingAnchor, constant: 0.0), bottomView.trailingAnchor.constraint(equalTo: g.trailingAnchor, constant: 0.0), bottomView.heightAnchor.constraint(equalToConstant: 280.0), btn.topAnchor.constraint(equalTo: bottomView.topAnchor, constant: 20.0), btn.trailingAnchor.constraint(equalTo: bottomView.trailingAnchor, constant: -20.0), ]) } }