使用我的尺寸在窗口中打开模态 ViewController

B2F*_*2Fq 2 modalviewcontroller ios swift

如何使用我的尺寸在窗口中打开模态 ViewController?

我尝试使用它,但它不起作用

modalViewController?.view.superview?.frame = CGRect(x:162, y: 333, width: 700,height: 700)
//
modalViewController?.view.superview?.center = self.view.center
Run Code Online (Sandbox Code Playgroud)

代码:

let modalViewController = self.storyboard?.instantiateViewController(withIdentifier: "Clipboard") as? ClipboardViewController
    modalViewController?.modalPresentationStyle = .overCurrentContext
    self.present(modalViewController!, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

例子:

在此处输入图片说明

Ger*_*eon 5

尝试:

let modalViewController = self.storyboard?.instantiateViewController(withIdentifier: "Clipboard") as? ClipboardViewController
modalViewController?.modalPresentationStyle = .formSheet
self.present(modalViewController!, animated: true, completion: nil)
modalViewController!.preferredContentSize = CGSize(width: 700, height: 700)
Run Code Online (Sandbox Code Playgroud)