最近在做的功能中有一個跳轉(zhuǎn)是這樣的,從界面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.跳轉(zhuǎn)問題
? ? 從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];
就是跳轉(zhuǎn)到了一個新的Navigation。如有更好的辦法歡迎分享。