簡體   English   中英

更改模式視圖的背景顏色

[英]Change Background Color of modal view

我想將viewcontroller視為大小為.formSheet的模式視圖。 背景顏色不應為灰色透明,而應為模糊效果。

我如何在模態后更改視圖的背景顏色。

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)
}

在此處輸入圖片說明

modalViewControllerviewWillAppear(:)方法中,可以訪問self.presentationController?.containerView屬性。 您可以根據需要更改背景顏色,甚至添加模糊效果視圖。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM