[英]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)
}
從modalViewController
的viewWillAppear(:)
方法中,可以訪問self.presentationController?.containerView
屬性。 您可以根據需要更改背景顏色,甚至添加模糊效果視圖。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.