如何在Modal View演示文稿中添加动画延迟swift iOS

时间:2018-02-19 07:31:44

标签: ios swift animation

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

如何使用更长的时间(例如2秒完成动画)为此视图设置动画

1 个答案:

答案 0 :(得分:0)

@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)
    }
}