最近在做的功能中有一个跳转是这样的,从界面A Present 到界面B,界面B背景要是透明的可以看到界面A,界面B上点击事件Push到界面C,大致是这样的。做的过程中遇到过一些问题,直接写一下最后的方案吧,笔记。
1.让B背景透明不会遮住A
设置A.definesPresentationContext = YES;
B.modalPresentationStyle = UIModalPresentationOverCurrentContext;
B.view.backgroundColor = [UIColor clearColor];
Tip:UIModalPresentationOverCurrentContext 作用是让B悬浮在A之上,想AlertView那样,definesPresentationContext 指定悬浮在哪个VC上,如果不设置会找Root,不设置有可能会界面错乱,我就遇到了这个问题。
2.跳转问题
从A Prentsent到一个NavigationVC,把B设置为NavigationVC的Root,这样做是可行的。
AudioSetPlayerViewController *audioSetVC = [[AudioSetPlayerViewController alloc]initWithNavigation:sourceVC.navigationController];
UINavigationController *nc = [[UINavigationController alloc]initWithRootViewController:audioSetVC];
nc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[sourceVCpresentViewController:nc animated:YES completion:nil];
就是跳转到了一个新的Navigation。如有更好的办法欢迎分享。