gpt4 book ai didi

swift - 如何在 Swift 中添加按钮来关闭模式

转载 作者:行者123 更新时间:2023-11-30 10:24:58 25 4
gpt4 key购买 nike

我在 Swift 中使用 present 显示一个模式,我想在它的左上角添加一个按钮,这样我就可以通过按下它来关闭模式。我怎样才能做到这一点?

@IBAction func touchCreateEvent(_ sender: UIButton) {
self.present(HomeViewController(), animated: true, completion: nil)
}

这是我显示模式的地方。我想要这个按钮,因为在以前的 iOS 版本中,我们没有向下滑动动画来关闭模式。

最佳答案

在 IBAction 内的 HomeViewController 中执行以下操作:

@IBAction func buttonAction(_ sender: UIButton) {
self.dismiss(animated: true, completion: nil)
}

关于swift - 如何在 Swift 中添加按钮来关闭模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60123233/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com