左右presentViewController经background黑问题
看效果图:
用例如以下代码,想弹出一个模态窗体,设置它的背景透明度为0.5,却发觉prsent后的背景色变为黑色的。
ShareVC *share = [[ShareVC alloc] init];
[self presentViewController:share animated:YES completion:nil];
起初还以为是设置透明度或者是[UIColor clearColor]出的问题,鼓捣几次之后发现不是这个问题。
google之后,在stackOverflow上找到几个比較靠谱的答案~
Why
Does presentModalViewController:animated: Turn The Background Black?
Display
clearColor UIViewController over UIViewController
终于结论为:
NavigationController and the View Controllers are designed in such a way that only one view controller may show at a time. When a new view
controller is pushed/presented the previous view controller will be hidden by the system. So when you reduce the modal view's alpha you will possibly see the window's backgroundColor (the black color you see now).
If you want a translucent view to slide-in over the main view, you can add the view as the subView of main view and animate it using UIView Animations.
所以还是改用为UIView Animations实现:
if (!_isShareViewOpen) { _isShareViewOpen = YES; ShareVC *shareVC = [[ShareVC alloc] initWithNibName:@"ShareVC" bundle:nil]; shareVC.shareVC = shareVC; shareVC.awardList = self; [self.view addSubview:shareVC.view]; [UIView animateWithDuration:0.75f animations:^{ shareVC.view.frame = CGRectMake(0, 640, self.view.frame.size.width, self.view.frame.size.height); shareVC.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); } completion:^(BOOL finished) { }]; }
--------------------------------------------------------------------------2014.09.26 再次编辑 ------------------------------------------------------------------
假设你不想用动画来实现 present 的效果,能够设置 presentViewController 的属性,一样能够达到以上效果:
presentingViewController.modalPresentationStyle = <span style="font-family: Arial, Helvetica, sans-serif;">UIModalPresentationCurrentContext</span>;
--------------------------------------------------------------------------2015.01.22 再次编辑 ------------------------------------------------------------------
以上代码仅仅是在 IOS7 中起作用。到 IOS8 就没用了,IOS8 能够用下面代码 fix:
_imagePickerCtrl.modalPresentationStyle = UIModalPresentationOverCurrentContext;
_imagePickerCtrl.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [appViews.rootViewController presentViewController:_imagePickerCtrl animated:YES completion:nil];
版权声明:本文博主原创文章,博客,未经同意不得转载。
左右presentViewController经background黑问题的更多相关文章
- js判断background颜色明暗色调,以设置白/黑字体颜色
整理自:jscolor.js插件 this.styleElement.style.color = this.isLight() ? '#000' : '#FFF'; this.isLight ...
- [FMX] Android APP 启动黑屏优化补丁
使用说明 *************************************************** Android APP 启动黑屏优化补丁 作者: Swish, YangYxd 201 ...
- ie8下jquery改变PNG的opacity出现黑边,ie6下png透明解决办法
目前互联网对于网页效果要求越来越高,不可避免的用到PNG图片,PNG分为几种格 式,PNG8 PNG24 PNG32,其中最常用的,也是显示效果和大小比较适中的则是PNG24,支持半透明,透明,颜色也 ...
- IOS UISearchDisplayController 点击搜索出现黑条问题解决方案
最近项目遇到一个很奇葩的问题 点击按钮启动 presentViewController 的时候出现下图效果: 代码: AddFriendViewController *addFriendVC = [[ ...
- PyOpenGL利用文泉驿正黑字体显示中文字体
摘要:在NeHe的OpenGL教程第43课源代码基础上,调用文泉驿正黑字体实现中文字体的显示 在OpenGL中显示汉字一直是个麻烦的事情,很多中文书籍的文抄公乐此不疲地介绍各种方法及其在windows ...
- Android 启动APP时黑屏白屏的三个解决方案
你会很奇怪,为什么有些app启动时,会出现一会儿的黑屏或者白屏才进入Activity的界面显示,但是有些app却不会如QQ手机端,的确这里要做处理一下.这里先了解一下为什么会出现这样的现象,其实很简单 ...
- android开发 解决启动页空白或黑屏问题
遇到的情况: app启动时进入启动页时出现白屏页,然后大概一秒之后就出现了背景图片. 原因:app启动时加载的是windows背景,之后再加载布局文件的,所以开始的黑屏/白屏就是windows的背景颜 ...
- 【安卓特效】怎样给ImageView加上遮罩,点击时泛黑、或泛白、?
基本思路: 方法1.遮罩可直接叠加一层带alpha的纯白.或纯黑View,可直接在ImageView外套一层FrameLayout,其foreground(一般同学可能仅仅知道background,事 ...
- presentViewController: 如何不覆盖原先的 viewController界面
PresentViewController 如何不遮挡住原来的viewController界面呢? 可能有时候会遇到这种需求,需要弹出一个功能比较独立的视图实现一些功能,但是却不想单纯添加一个View ...
随机推荐
- POJ2599+POJ2082【最大矩形面积】
题目链接:http://poj.org/problem?id=2559 题目链接:http://poj.org/problem?id=2082 这一类题目的解法,不知自己闲着没事就做了两个. 果然压栈 ...
- 【CSS3】transform-origin原点旋转
忙乱, 点 -moz-transform-origin: 0 0; -webkit-transform-origin:0 0; -o-transform-origin:0 0; 以右上角给原点 -mo ...
- debian下使用siege进行压力测试
一:siege siege是开源的一个测试工具,可以对指定文本的URL列表进行负载测试,也可以在执行其他请求前让某个请求休眠,从而让你感觉某个用户在转移到web应用的下一个文档前正在读取该文档. ht ...
- 《深入理解OSGi:Equinox原理、应用与最佳实践》笔记_2_建立开发环境
本文对应书本5.1.3的内容 书本中通过CVS下载的源码 但是笔者实践的时候发现无法下载...地址已经失效了(也许是笔者的失误输错地址所致) 可以用git下载 地址是: http://git.ecli ...
- 物联网 开发板 基于ESP8266
The ESP8266 The ESP8266 is a highly integrated chip designed for the needs of an increasingly connec ...
- 09_android入门_採用android-async-http开源项目的GET方式或POST方式实现登陆案例
依据08_android入门_android-async-http开源项目介绍及用法的介绍,我们通过最常见的登陆案例进行介绍android-async-http开源项目中有关类的使用.希望对你学习an ...
- 流动python - 一个极简主义event制
event至少该系统的核心,以满足: 1.存储容器事件,可以被添加到事件来删除 2.触发事件fire 守则. class Event(list): def __call__(self, *args, ...
- The Swift Programming Language 中国版
iSwifting社会的 Swift 兴趣交流群:303868520 iOS 微信公众账号:iOSDevTip Swift 微信公众账号:SwiftDev iSwifting社区 假设你认为这个项目不 ...
- u-boot 的bootcmd 和bootargs详解,烧写分析
下面链接这篇文章也非常重要,介绍DM3X的一系列烧写步骤和设置方法 http://www.61ic.com/Article/DaVinci/TMS320DM3x/201204/41827.html U ...
- Cocos2d-x3.1 粒子效果演示样例
这里把粒子的几种效果粘出来,以便以后使用 原文地址:http://blog.csdn.net/qqmcy/article/details/37511259 // // IntervalLayer.cp ...