学了活用才是正道。
popUpView = [[YSAMPopupView alloc]initWithNibName:nil bundle:nil];
popUpView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; UIViewController *controller = self.view.window.rootViewController;
controller.modalPresentationStyle = UIModalPresentationCurrentContext;
//弹出
[controller presentModalViewController:popUpView animated:NO];
//隐藏
[popUpView dismissModalViewControllerAnimated:NO];
ModalViewController可以有不同的呈现类型(modalPresentationStyle),列举如下:
1. UIModalPresentationFullScreen // 全屏模式。即弹出窗口占满整个屏幕,在portrait模式和landscape模式下都一样。
2. UIModalPresentationFormSheet // 会将窗口缩小,使之居于屏幕中间。在portrait和landscape下都一样,但要注意landscape下如果软键盘出现,窗口位置会调整。
3. UIModalPresentationPageSheet // 在portrait时是FullScreen,在landscape时和FormSheet模式一样。
4. UIModalPresentationCurrentContext // 跟父窗体一样
有四种切换形式(modalTransitionStyle):
UIModalTransitionStyleFlipHorizontal
UIModalTransitionStyleCoverVertical (default)
UIModalTransitionStyleCrossDissolve
UIModalTransitionStylePartialCurl
本文介绍了iOS中ModalViewController的不同呈现类型及切换形式,并提供了具体的代码实现方式。
187

被折叠的 条评论
为什么被折叠?



