iOS8以iOS8以下的系统present一个半透明的ViewController的方法

本文介绍了一种在iOS应用中实现复杂引导页面的方法,通过使用ViewController而非简单的View进行管理,以便于更好地处理逻辑并便于后期维护。文中还详细介绍了如何根据不同iOS版本调整呈现样式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

起因

需求需要做一个引导页面,这个引导页的逻辑处理较多,如果单独一个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];
        }];
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值