左右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 ...
随机推荐
- ffplay2 android 版正式公布
项目地址:https://github.com/DeYangLiu/AndroidPlayer/ 下载链接: 看点: 支持软键盘输入和历史记录.使用了EditText和内部存储. 这里考虑了历史记录的 ...
- zend framework将zip格式的压缩文件导入并解压到指定文件
html代码 <pre class="php" name="code"><fieldset> <legend>批量导入学生照 ...
- java 线程 ProducerAndConsumer
package j2se.thread.demo; /** * <p>Project:J2SE 的基础知识</p> * <p>Tile:多线程模拟 生产者 和 消费 ...
- 启动、停止、重启 MySQL 常见的操作方法:
启动.停止.重启 MySQL 常见的操作方法: 简单罗列 一.启动方式 1.使用 service 启动:service mysqld start 2.使用 mysqld 脚本启动:/etc/inint ...
- WebSocket API
WebSocket API 这一章介绍如何用WebSocket API来控制协议和创建应用,运用http://websocket.org 提供的现有WebSocket服务器,我们可以收发消息.创建一些 ...
- win7系统u盘安装过程
1.准备好带有启动项的U盘,并把镜像解压到里面去 2.插上u盘,开机长按del键进入bois设置界面 在boot页面 1.boot device priority->1st boot devic ...
- SVNKIT一段代码的分析
打印SVNkit版本库中的结构: 函数如下: 调用方法如下: listEntries(repository, ""); System.out.println("XXXXX ...
- Java equals 和 hashcode 方法
问题 面试时经常会问起字符串比较相关的问题, 总结一下,大体是如下几个: 1.字符串比较时用的什么方法,内部实现如何? 2.hashcode的作用,以及重写equal方法,为什么要重写hashcode ...
- java 通过sftp服务器上传下载删除文件
最近做了一个sftp服务器文件下载的功能,mark一下: 首先是一个SftpClientUtil 类,封装了对sftp服务器文件上传.下载.删除的方法 import java.io.File; imp ...
- 官方原版Windows XP SP3(VOL)中文简体版ISO下载
今天,向各位朋友推荐今年五月,由MSDN官方集成的XP With SP3专业VOL版. 文 件:Windows XP Professional with Service Pack 3 (x86) ...