美文网首页iOS菜鸟食谱
iOS8以iOS8以下的系统present一个半透明的ViewC

iOS8以iOS8以下的系统present一个半透明的ViewC

作者: xnxin | 来源:发表于2015-08-29 11:49 被阅读1081次

    起因

    需求需要做一个引导页面,这个引导页的逻辑处理较多,如果单独一个View,不方便管理与后期的维护,所以需要做成ViewController来管理和维护
    下面直接分享一下我的源码

    RecommandViewController *recommandVC = [[RecommandViewController alloc]init];
        if([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0){
            recommandVC.modalPresentationStyle=
            UIModalPresentationOverCurrentContext|UIModalPresentationFullScreen;//if the controller has container like navigationcontroller or tababr controlelr,if you don`t use the UIModalPresentationFullScreen the bar will cover the viewcontroller
            [FindAppDelegate().window.rootViewController presentViewController:recommandVC animated:NO completion:^{
                recommandVC.view.backgroundColor=[UIColor clearColor];//you can figure any transparent here
            }];
        }else{
            FindAppDelegate().window.rootViewController.modalPresentationStyle=
            UIModalPresentationCurrentContext|UIModalPresentationFullScreen;//you must use the rootViewController if the system version under the iso 8.0 or the background will be black
            [FindAppDelegate().window.rootViewController presentViewController:recommandVC animated:YES completion:^{
                recommandVC.view.backgroundColor=[UIColor clearColor];
            }];
        }
    

    相关文章

      网友评论

        本文标题:iOS8以iOS8以下的系统present一个半透明的ViewC

        本文链接:https://www.haomeiwen.com/subject/ysvkcttx.html