首页 > 解决方案 > 如何在 3 秒后显示新的视图控制器

问题描述

单击按钮后,我想显示一个新的 ViewController,但不是直接显示。单击按钮后,我想等待 3 秒,然后在 3 秒后我想要新的 ViewController

标签: iosswiftuiviewcontroller

解决方案


在单击按钮时添加延迟:

DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
   // Your code with navigate to another controller
}

推荐阅读