我将 View Controller 用作模态。我想指定它从下到上的高度。这意味着它从底部打开到它的高度。我使用下面的代码打开模式:
let popUpVc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "NewController") as! NewController
self.addChildViewController(popUpVc)
//Transition from bottom
let transition = CATransition()
transition.duration = 0.5
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromTop
view.window!.layer.add(transition, forKey: kCATransition)
popUpVc.view.frame = self.view.frame
self.view.addSubview(popUpVc.view)
popUpVc.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
popUpVc.didMove(toParentViewController: self)
请帮帮我..
最佳答案
阅读您的评论似乎您想用模态视图 Controller 覆盖父 View 的下半部分。如果你正在使用 Storyboard,你可以使用一个包含的 View Controller 很容易地做到这一点……
在下面的示例中,显示 按钮以模态方式呈现包含 View Controller ,呈现类型为在当前上下文中。
View Controller 有一个清晰的背景,一个包含 View 设置为它一半的高度。包含的(黄色) View Controller 有一个关闭按钮,连接到绿色 View Controller 中的展开转场。
@IBAction func unwind(_ segue: UIStoryboardSegue) { }
所有这些只需一行代码!
关于ios - 如何从下到上呈现部分高度模态视图 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52197588/