如何让viewcontroller在ios10 swift3中显示为底层页面?
问题描述:
我有一个按钮,一个视图控制器,如果我按一下按钮,它应该出现(在Android的像底页)底部视图控制器:如何让viewcontroller在ios10 swift3中显示为底层页面?
我有这两个演示图控制器,如果我点击按钮第二个视图控制器应该只显示细节视图,它应该从第一个视图控制器的底部弹出。
谢谢。
答
为了实现它,你应该添加第二个视图控制器作为子视图控制器并从底部开始动画。 添加孩子:
let secondViewControllerInstance = SecondViewController() // or by Storyboard
instantiate method
self.addChildViewController(secondViewControllerInstance)
let initialRect = CGRect(x: 0, y: SCREEN_HEIGHT-200, width: SCREEN_WIDTH,
height: 200)
secondViewControllerInstance.view.frame = rect
secondViewControllerInstance.view.center.y += 100
self.view.addSubview(secondViewControllerInstance.view)
secondViewControllerInstance.didMove(toParentViewController: self)
//Animate center y
UIView.animate(withDuration: 0.3) {
secondViewControllerInstance.view.center.y -= 100
}
根据您的要求调整高度和宽度。
你是什么意思的'在Android'的底部页面。你能更具体一点吗?添加你到目前为止尝试过的代码。或者你想要实现的图像。 –
我想你需要Tabbarcontroller或其他 –
你能分享Android底部页面的截图吗? – abhishekkharwar