我的目标是以编程方式将 UIViewController 呈现为弹出窗口。
如您所见,过渡样式设置为 Cross Dissolve
,演示文稿设置为 Over current context
。所以从技术上讲,如果我单击按钮,转换就会起作用,我的目标是以编程方式进行。
func clickButton() {
//What should I do here?
}
如何在 clickButton
上以编程方式显示弹出窗口?
最佳答案
如果您以模态方式呈现 View Controller 。你可以这样做。
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)
}
}
关于ios - 如何使用 Swift 以编程方式在 iOS 中显示弹出窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45457257/