UITabBarController弹出透明模态视图的问题

应用要求:底层是tabbarController,tabbar中的controller是navigationController,弹出一个透明的模态视图遮住全屏幕,包括底部的tabbar和顶部的navigationBar,按照http://www.jianshu.com/p/bf3325111fe5的解决方案可以解决遮挡navigationBar的问题,

代码为:

self.tabBarController.definesPresentationContext = YES;

segue.destinationViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;

但是上述代码不能解决遮挡tabbar的问题,根据http://siroccoicode.club/?p=209的思路,我结合了上述两个作者的方案,最终解决代码如下:

AppDelegate *appdelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];

UIViewController *view = [[UIViewController alloc]init];

appdelegate.window.rootViewController.definesPresentationContext = YES;

view.modalPresentationStyle = UIModalPresentationOverCurrentContext;

[appdelegate.window.rootViewController presentViewController:view animated:YES completion:^{

view.view.backgroundColor=[UIColor colorWithRed:237/255.0 green:236/255.0 blue:244/255.0 alpha:0.5];

}];

就是利用AppDelagate获得一个rootController,在rootController上操作。在此分享给大家!

在此感谢上述两位作者提供的思路。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容