美文网首页
presentViewController 半透明 变黑

presentViewController 半透明 变黑

作者: kid_add | 来源:发表于2019-07-11 10:57 被阅读0次

MSTestViewController *vc = [[MSTestViewController alloc] init];

vc.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];

float version = [UIDevice currentDevice].systemVersion.floatValue;

if (version < 8.0) { // iOS 7 实现的方式略有不同(设置self)

self.modalPresentationStyle = UIModalPresentationCurrentContext;

// iOS8以下必须使用rootViewController,否则背景会变黑

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

}];

} else { // iOS 8 以上实现(设置vc)

vc.modalPresentationStyle = UIModalPresentationOverCurrentContext|UIModalPresentationFullScreen;

//如果控制器属于navigationcontroller或者tababrControlelr子控制器,不使用UIModalPresentationFullScreen 的话, bar 会盖住你的modal出来的控制器

[self presentViewController:vc animated:YES completion:^{

// 也可以在这里做一些完成modal后需要做得事情

}];

}

相关文章

网友评论

      本文标题:presentViewController 半透明 变黑

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