利用模态弹出VC实现类似AlertView的透明黑色背景

2016-05-27  本文已影响63人  小黄人写代码
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    
UIViewController *vc = [[UIViewController alloc] init];
appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
[appDelegate.window.rootViewController presentViewController:vc animated:YES completion:^{
    vc.view.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.8];
    appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
}];
TestController *vc = [[TestController alloc] init];
vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:vc animated:NO completion:^{
        vc.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.8];
}];
上一篇 下一篇

猜你喜欢

热点阅读