如何通过单击swift中的按钮在同一屏幕上打开另一个视图

时间:2017-04-04 15:55:57

标签: ios swift

我想通过点击按钮打开另一个视图的视图。我正在附上它,以便更好地理解。

This image is my desired output

This image is my base view, which you can see in my desired one at the back side, with less opacity

如果有人有任何想法,请帮助我..

1 个答案:

答案 0 :(得分:1)

您可以使用此库(MZFormSheetPresentationController)创建具有图像,按钮和许多功能的警报视图。您可以按预期设计viewController。

func formSheetControllerWithNavigationController() -> UINavigationController {
                return self.storyboard!.instantiateViewController(withIdentifier: "formSheetController") as! UINavigationController
}

func passDataToViewControllerAction() {

            let navigationController = self.formSheetControllerWithNavigationController()
            let formSheetController = MZFormSheetPresentationViewController(contentViewController: navigationController)
            formSheetController.presentationController?.isTransparentTouchEnabled = false
            formSheetController.presentationController?.shouldCenterVertically = true
            formSheetController.presentationController?.shouldCenterHorizontally = true
            formSheetController.presentationController?.shouldDismissOnBackgroundViewTap = true

            let yourViewController = navigationController.viewControllers.first as! EventDisplayViewController

            yourViewController.delegate = self



            self.present(formSheetController, animated: true, completion: nil)
}