有没有办法在iOS中呈现ViewController,同时保持呈现的ViewController可见?现在,一旦动画结束,PresentingViewController似乎就会被隐藏。
答案 0 :(得分:1)
使用UIModalPresentationStyle
中的值来控制此值。
UIModalPresentationPageSheet
或UIModalPresentationFormSheet
将导致演示文稿在下方留下一定数量的呈现视图控制器。
在呈现的视图控制器上设置modalPresentationStyle
e.g
presentedViewController.modalPresentationStyle = UIModalPresentationFormSheet;
[presentingViewController presentViewController:presentedViewController animated:YES completion:nil];
答案 1 :(得分:0)
显示:
if let popupVC = storyboard.instantiateViewControllerWithIdentifier("PopupVC") as? PopupVC
{
var frame = UIScreen.mainScreen().bounds
frame.origin.y = frame.size.height
overlayWindow = UIWindow(frame: frame)
popupVC.overlayWindow = overlayWindow
overlayWindow.windowLevel = UIWindowLevelAlert
overlayWindow.rootViewController = popupVC
overlayWindow.makeKeyAndVisible()
UIView.animateWithDuration(0.3, animations:
{
self.overlayWindow.frame.origin.y = 0
})
}
在PopupVC中隐藏
if let window = overlayWindow
{
UIView.animateWithDuration(0.3, animations: {
window.frame.origin.y = window.frame.height
}, completion: { (finished) -> Void in
self.overlayWindow = nil
})
}