简体   繁体   中英

Change Background Color of modal view

I would like to resent an viewcontroller as modal view in size .formSheet. The background color should not be grey transparent, it should be an blur effect.

How I cloud change the background color of view behind modal.

let storyboard = UIStoryboard(name: "DetailViewController", bundle: nil)
if let modalViewController = storyboard.instantiateInitialViewController() as? DetailViewController {
    self.definesPresentationContext = true
    self.providesPresentationContextTransitionStyle = true
    modalViewController.item = item
    modalViewController.modalPresentationStyle = .formSheet
    modalViewController.modalPresentationCapturesStatusBarAppearance = true

    self.present(modalViewController, animated: true, completion: nil)
}

在此处输入图片说明

From the viewWillAppear(:) method of your modalViewController , you can access the self.presentationController?.containerView property. You can either change the background color or even add a blur effect view if you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM