Transparent ViewController to See Parent Below?

后端 未结 9 977
自闭症患者
自闭症患者 2021-02-01 18:59

I would like to modally add a view controller with a transparent background, so the parent view controller beneath can be seen. (This is in an app for iPhone, not for iPad.)

9条回答
  •  南旧
    南旧 (楼主)
    2021-02-01 19:38

    Answer for Swift 5.

    TransparentViewController

    self.view.backgroundColor = .clear
    

    PresentingViewController

    let viewController = TransparentViewController()
    viewController.modalPresentationStyle = .overFullScreen
    navigationController.present(viewController, animated: false)
    

提交回复
热议问题