iOS模态出来一个半透明的控制器且子空间不透明

2017-07-12  本文已影响18人  七里田间的守望者

小编废话不多说直接上代码

MonsterServeViewController * serveVC = [[MonsterServeViewController alloc]initWithNibName:@"MonsterServeViewController" bundle:nil];

serveVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:serveVC animated:YES completion:nil];

//iOS8 是UIModalPresentationOverCurrentContext
//iOS7是UIModalPresentationCurrentContext

上面设置完成还不够
还需要做下面的操作

self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.65];

!!!至此搞定,其实这个不难。只是教程少很少有人注意到这个细节
如果解决了您的问题还烦请观众老爷们给小弟个赞~鼓励鼓励!!!

上一篇 下一篇

猜你喜欢

热点阅读