我有两个视图控制器,我想呈现第一个视图控制器的视图控制器(VC)。第二个VC的大小较小。我想在第一个VC上显示第二个视图控制器。就像弹出框一样。你可以想象一下,如果我们添加另一个视图控制器从底部向上滑动,但停在导航栏。
这是我的代码:
@IBAction func showSecondVC(sender: AnyObject) {
let secondViewController = storyboard?.instantiateViewControllerWithIdentifier("SecondViewController") as! SecondViewController
secondViewController.view.frame = CGRect(origin: CGPoint(x: view.frame.origin.x, y: header.frame.height), size: CGSize(width: view.frame.width, height: view.frame.height - header.frame.height))
secondViewController.definesPresentationContext = true
secondViewController.providesPresentationContextTransitionStyle = true
secondViewController.modalPresentationStyle = UIModalPresentationStyle.CurrentContext
self.presentViewController(secondViewController, animated: true, completion:nil)
}
您可以看到,我为secondViewController
设置了一个框架。我希望它将按照这个框架显示,但如果我添加完成块并在动画后显示它的框架,它将与第一个视图控制器相同。
编辑
我还想提到,我尝试在竖直方向上实现这个目标。