在我的视图控制器中,我有这个函数:
...{
let vc = UIHostingController(rootView: SwiftUIView())
present(vc, animated: true, completion: nil)
}
如何展示下面的SwiftUIView。
Q 当自定义按钮按下时,如何关闭SwiftUIView?
struct SwiftUIView : View {
var body: some View {
CustomButton()
}
}
struct CustomButton: View {
var body: some View {
Button(action: {
self.buttonAction()
}) {
Text(buttonTitle)
}
}
func buttonAction() {
//dismiss the SwiftUIView when this button pressed
}
}