如何在Swift

时间:2020-02-08 01:47:17

标签: swift

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

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

这是我显示模态的地方。我想要该按钮,因为在以前的iOS版本中,我们没有向下滑动动画以消除模态。

1 个答案:

答案 0 :(得分:0)

在IBAction内部的HomeViewController中执行

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