如何使用Swift在iOS中以编程方式呈现弹出式窗口?

sin*_*Gob 0 ios swift

我的目标是以编程方式将UIViewController呈现为弹出窗口。

在此处输入图片说明

如您所见,过渡样式设置为Cross Dissolve,演示文稿设置为Over current context。因此,从技术上讲,如果我单击该按钮,过渡将起作用,我的目标是以编程方式进行操作。

func clickButton() {
     //What should I do here?   


 }
Run Code Online (Sandbox Code Playgroud)

如何以编程方式显示弹出窗口clickButton

Bil*_*lal 5

如果您以模态呈现视图控制器。你可以这样

func clickButton() {
    if let vc = self.storyboard?.instantiateViewController(withIdentifier:"YOUR_VIEW_CONTROLLER_ID") {
        vc.modalTransitionStyle   = .crossDissolve;
        vc.modalPresentationStyle = .overCurrentContext
        self.present(vc, animated: true, completion: nil)
    }
}
Run Code Online (Sandbox Code Playgroud)