iOS 模拟出一个半透明的ViewController presentViewController 实现
来源:互联网 发布:什么软件获得集分宝 编辑:程序博客网 时间:2024/05/19 22:03
最近项目有需求, 需要模态初一个半透明的视图, 好多人都碰到这个问题吧, 在目标视图中设置背景颜色然后发现模态动作结束后变成了黑色或者不是半透明的颜色。
所以今天来告诉大家解决方案
- (IBAction)Avtion1:(id)sender { TestViewController * testVC = [TestViewController new]; self.definesPresentationContext = YES; //self is presenting view controller testVC.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.4]; testVC.modalPresentationStyle = UIModalPresentationOverCurrentContext; [self presentViewController:testVC animated:YES completion:nil];}
- 注意:如果present 一个NavController,不能完全使用上面代码。
- (IBAction)pushSecond:(id)sender{
SecondViewController * testVC = [SecondViewController new];
self.definesPresentationContext = YES; //self is presenting view controller
testVC.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.5];
// testVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:testVC];
nav.modalPresentationStyle = UIModalPresentationOverCurrentContext;
nav.view.backgroundColor = [UIColor clearColor];
[self presentViewController:nav animated:YES completion:nil];
}
- definesPresentationContext
/* Determines which parent view controller's view should be presented over for presentations of type UIModalPresentationCurrentContext. If no ancestor view controller has this flag set, then the presenter will be the root view controller.*/
- backgroundColor
设置你的背景颜色
- modalPresentationStyle
/* Defines the transition style that will be used for this view controller when it is presented modally. Set this property on the view controller to be presented, not the presenter. Defaults to UIModalTransitionStyleCoverVertical.*/
Demo 如下 :
https://github.com/lihongli528628/PreDemo
- iOS 模拟出一个半透明的ViewController presentViewController 实现
- presentViewController 弹出半透明ViewController
- prensent一个半透明的viewcontroller 或者push 出一个viewcontroller 做present 动画
- presentViewController弹出一个半透明的UIViewController
- 在iOS上present一个半透明的viewController
- IOS实现翻转一个View显示presentViewController
- presentViewController 方法中实现半透明背景效果
- presentViewController: 如何不覆盖原先的 viewController界面
- 多次presentViewController后,直接返回到初始的viewcontroller
- IOS弹出一个半透明的框
- iOS模态出一个半透明的ViewControlle
- iOS8以iOS8以下的系统present一个半透明的ViewController的方法
- iOS8以iOS8以下的系统present一个半透明的ViewController的方法
- 【转】ios 半透明模糊效果的实现
- modal出一个viewController时隐藏状态栏
- 模拟一个先进先出的队列
- iOS presentViewController的时候有卡顿或延迟
- iOS 7.0 presentViewController 背景变黑的解决办法
- 大数据,数据分析场景分析。
- 用VBA导出Excel里的图表为JPG文件
- plsql developer登录页面的database中没有选项问题
- Material Design开发文章系列2:在你的App中实现Material Design
- 关于 InnoDB 索引长度限制的 tips
- iOS 模拟出一个半透明的ViewController presentViewController 实现
- struts2的result type属性说明
- java动态代理(JDK和cglib)
- 重定向与转发的区别
- leetcode Implement Trie (Prefix Tree)
- Struts2 中的值栈的理解
- 《算法的乐趣》作者王晓华访谈:多看、多做、多想是秘诀
- visual studio 2013 生成依赖项关系图出错
- 利用极光api实现 通过php(thinkphp)服务端推送信息