ios - 如何在 Modal View presentation swift iOS 中添加动画延迟

标签 ios swift animation

@objc func popCartView(tapGestureRecognizer: UITapGestureRecognizer)
{
    let modalViewController = CartViewController()
    modalViewController.modalPresentationStyle = .overCurrentContext
    self.present(modalViewController, animated: true, completion: nil)
}

如何用更多的时间(比如 2 秒来完成动画)为这个 View 设置动画

最佳答案

@objc func popCartView(tapGestureRecognizer: UITapGestureRecognizer)
{
    let modalViewController = CartViewController()
    modalViewController.modalPresentationStyle = .overCurrentContext
    DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
        // Your code with delay
        self.present(modalViewController, animated: true, completion: nil)
    }
}

关于ios - 如何在 Modal View presentation swift iOS 中添加动画延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48861349/

相关文章:

iphone - View Controller - 来自文档的建议

ios - IOS Swift 中的容器 View 中未触发按钮操作

ios - 带有按钮和选择器的协议(protocol)扩展

ios - 流畅地动画化 UISlider

android - 打开和关闭带有动画的 Activity 不在按下后工作但在打开时工作

ios - 我们为 AVCaptureSession 选择哪种像素格式类型来使用 Vision 运行 CoreML 模型有关系吗?

ios - 快速控制流程

ios - 修复了顶部 UITableView 中的 UIImage

ios - 如何在后台应用程序时在键盘前面显示keyWindow?

javascript - CSS 过渡和 JS 同时切换