最近在做的功能中有一個跳轉(zhuǎn)是這樣的论矾,從界面A Present 到界面B教翩,界面B背景要是透明的可以看到界面A,界面B上點(diǎn)擊事件Push到界面C贪壳,大致是這樣的饱亿。做的過程中遇到過一些問題,直接寫一下最后的方案吧闰靴,筆記彪笼。
1.讓B背景透明不會遮住A
? ? 設(shè)置A.definesPresentationContext = YES;
? ? B.modalPresentationStyle =?UIModalPresentationOverCurrentContext;
? ? B.view.backgroundColor = [UIColor clearColor];
Tip:UIModalPresentationOverCurrentContext 作用是讓B懸浮在A之上,想AlertView那樣蚂且,definesPresentationContext 指定懸浮在哪個VC上配猫,如果不設(shè)置會找Root,不設(shè)置有可能會界面錯亂杏死,我就遇到了這個問題泵肄。
2.跳轉(zhuǎn)問題
? ? 從A Prentsent到一個NavigationVC,把B設(shè)置為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零渐。如有更好的辦法歡迎分享窒舟。