iOS8下 presentViewController的透明部分 变成黑色不透明了

本文解决了 iOS8 下使用 UIModalPresentationCurrentContext 导致弹出视图背景变黑的问题。通过版本判断使用不同的 modalPresentationStyle,确保了在 iOS8 及以上版本中正确实现半透明背景效果。

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

iOS8下 原来presentViewController的画面(不是全画面,画面以外地方透明)的透明部分 变成黑色不透明了


换句话说,self.modalPresentationStyle = UIModalPresentationCurrentContext;不好用了





今天试了无数个方法终于找到了解决方法。


ios8多了一个样式UIModalPresentationOverCurrentContext,跟原来的很相近哦。而且定义的对象也变成了弹出的视图。


所以用的话做版本判断:


if ([[[UIDevice currentDevicesystemVersionfloatValue]>=8.0) {


        nextVC.modalPresentationStyle=UIModalPresentationOverCurrentContext;


    }else{


        self.modalPresentationStyle=UIModalPresentationCurrentContext;


    }


    [self presentViewController: nextVC animated:YES completion:nil];


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值