iosswiftxcodeuimodalpresentationstyle

Replace the viewcontroller without it appearing behind it


My issue occurs when changing the VC, the old VC continues to appear in the background (see screen capture). How can I fix it?

Thank you for your help.


Solution

  • The sheet presentation style appears as a card. To make it fullscreen use this.

    let vc = UIViewController()
    vc.modalPresentationStyle = .fullScreen //or .overFullScreen for transparency
    self.present(vc, animated: true, completion: nil)