美文网首页
iOS 设置调转界面控制器的view的半透明状态( 弹出一个透明

iOS 设置调转界面控制器的view的半透明状态( 弹出一个透明

作者: iOS开发小学生 | 来源:发表于2018-07-10 00:15 被阅读346次

在我们普通的只是在下一个控制器里设置界面的透明度是不起作用的,所以我们要进行下面的操作,才能使控制器界面完美的实现透明效果。

第一种写法

 NextViewController *next = [[NextViewController alloc] init];

    next.providesPresentationContextTransitionStyle = YES;

    next.definesPresentationContext = YES;

    [next setModalPresentationStyle:UIModalPresentationOverCurrentContext];

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

在写一个界面的 viewDidLoad 方法中在进行设置背景颜色透明就OK 

colorWithAlphaComponent 颜色透明方法

第二种写法

    NextViewController * next = [[NextViewController alloc]init];

     next.definesPresentationContext = YES;

     UIColor *color = [UIColor blackColor];

     next.view.backgroundColor = [color colorWithAlphaComponent:0.5];

     next.modalPresentationStyle = UIModalPresentationOverCurrentContext;

     [self presentViewController:next animated:NO completion:nil];

相关文章

网友评论

      本文标题:iOS 设置调转界面控制器的view的半透明状态( 弹出一个透明

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