ios - 如何使用 Swift 以编程方式在 iOS 中显示弹出窗口?

标签 ios swift

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

enter image description here

如您所见,过渡样式设置为 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/

相关文章:

ios - Swift 2.3 到 Swift 3.1 迁移 - StatusBar 下的 EZSwipeViewController

ios - 预期的表达式错误 Xcode

ios - 初始化程序不会在 swift 中从其父类(super class)错误中覆盖设计的初始化程序

ios - 如何过滤二维数组

swift - RxSwift 中的乐观 UI 更新

ios - 如何复制两个标签的结果?

floating-point - 为什么 Swift 使用以 2 为底的十六进制浮点值的指数?

ios - MKMapView 中 showsUserLocation 的不稳定行为

iOS - 如何创建带阴影的 "material design"兼容 UIView?

iphone - 如何在 iOS 中制作可 ScrollView ?