ViewController as Overlay on MapView in Swift (like Google Maps Application User Interface)

一笑奈何 提交于 2019-12-04 17:14:32

I've finally managed to get what I wanted by manually adding a ViewController and a view like this:

let detailsWidth: CGFloat = view.bounds.width
let detailsHeight: CGFloat = 150
let detailsViewFrame: CGRect = CGRectMake(0, view.bounds.height, detailsWidth, detailsHeight)

detailsController = storyboard?.instantiateViewControllerWithIdentifier("details") as! DetailsViewController
detailsController.descriptionText = "I'm a text that was passed from the MainViewController"

self.addChildViewController(detailsController)
detailsController.view.frame = detailsViewFrame
view.addSubview(detailsController.view)
detailsController.didMoveToParentViewController(self)

And when dismissing the Details, I remove the Controller like this:

self.detailsController.removeFromParentViewController()

I created a small sample to demonstrate my solution: https://github.com/flavordaaave/iOS-Container-View-Overlay

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!