看效果图:

用例如以下代码,想弹出一个模态窗体,设置它的背景透明度为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];

參考链接:

f=2&t=18661" style="color:rgb(107,168,47); font-family:Georgia,'Microsoft YaHei',微软雅黑,宋体,'Times New Roman',Arial,Helvetica,sans-serif; font-size:15px; line-height:27.75px; text-indent:30px">http://www.raywenderlich.com/forums/viewtopic.php?

f=2&t=18661

版权声明:本文博主原创文章,博客,未经同意不得转载。

左右presentViewController经background黑问题的更多相关文章

  1. js判断background颜色明暗色调,以设置白/黑字体颜色

    整理自:jscolor.js插件   this.styleElement.style.color = this.isLight() ? '#000' : '#FFF';   this.isLight ...

  2. [FMX] Android APP 启动黑屏优化补丁

    使用说明 *************************************************** Android APP 启动黑屏优化补丁 作者: Swish, YangYxd 201 ...

  3. ie8下jquery改变PNG的opacity出现黑边,ie6下png透明解决办法

    目前互联网对于网页效果要求越来越高,不可避免的用到PNG图片,PNG分为几种格 式,PNG8 PNG24 PNG32,其中最常用的,也是显示效果和大小比较适中的则是PNG24,支持半透明,透明,颜色也 ...

  4. IOS UISearchDisplayController 点击搜索出现黑条问题解决方案

    最近项目遇到一个很奇葩的问题 点击按钮启动 presentViewController 的时候出现下图效果: 代码: AddFriendViewController *addFriendVC = [[ ...

  5. PyOpenGL利用文泉驿正黑字体显示中文字体

    摘要:在NeHe的OpenGL教程第43课源代码基础上,调用文泉驿正黑字体实现中文字体的显示 在OpenGL中显示汉字一直是个麻烦的事情,很多中文书籍的文抄公乐此不疲地介绍各种方法及其在windows ...

  6. Android 启动APP时黑屏白屏的三个解决方案

    你会很奇怪,为什么有些app启动时,会出现一会儿的黑屏或者白屏才进入Activity的界面显示,但是有些app却不会如QQ手机端,的确这里要做处理一下.这里先了解一下为什么会出现这样的现象,其实很简单 ...

  7. android开发 解决启动页空白或黑屏问题

    遇到的情况: app启动时进入启动页时出现白屏页,然后大概一秒之后就出现了背景图片. 原因:app启动时加载的是windows背景,之后再加载布局文件的,所以开始的黑屏/白屏就是windows的背景颜 ...

  8. 【安卓特效】怎样给ImageView加上遮罩,点击时泛黑、或泛白、?

    基本思路: 方法1.遮罩可直接叠加一层带alpha的纯白.或纯黑View,可直接在ImageView外套一层FrameLayout,其foreground(一般同学可能仅仅知道background,事 ...

  9. presentViewController: 如何不覆盖原先的 viewController界面

    PresentViewController 如何不遮挡住原来的viewController界面呢? 可能有时候会遇到这种需求,需要弹出一个功能比较独立的视图实现一些功能,但是却不想单纯添加一个View ...

随机推荐

  1. CheckBox和RadioButton以及RadioGroup

    CheckBox:复选框 有两种状态 选中状态(true),未选状态(false) 属性 android:checked= "false"(表示该复选框未被选中) RadioGro ...

  2. 启动和关闭JBoss As 7.1.1脚本

    启动和关闭JBoss As 7.1.1,脚本例如以下djboss.sh: #!/bin/sh #JBOSS_HOME JBOSS_HOME=/opt/jboss case "$1" ...

  3. linux kickstart 自动安装

    最近很多业务系统都是linux lnmp平台安装,反复的安装让人觉得很苦恼,仔细钻研了下kickstart .这里环境是red hat linux 5.8 32位,系统盘中的软件包里包含有kickst ...

  4. gem5 设定checkpiont以及从checkpoint开始运行

    同spec2006中间bzip2一个例子,如何设置checkpoint .以及从checkpoint继续以启动运行.这样做的目的是为了,采纳automic运行N指令,然后detailed运行M指令. ...

  5. 谈Web应用系统的可维护性

           每一个软件开发人员都十分清楚, 当软件构建得越来越复杂时, 可维护性就成了一个很突出的问题. 如何在构造软件系统的过程中始终保持可控制的可维护性呢?          一. 整体组织   ...

  6. cocos2d-x ndk adt mac 路径配置

    export PATH=/bin:/sbin:/usr/local/mysql/bin export PATH=$PATH:/Applications/MacVim-snapshot-68 expor ...

  7. Learning Cocos2d-x for WP8(9)——Sprite到哪,我做主

    原文:Learning Cocos2d-x for WP8(9)--Sprite到哪,我做主 工程文件TouchesTest.h和TouchesTest.cpp 相关素材文件 事件驱动同样适用于coc ...

  8. 图像库---Image Datasets---OpenSift源代码---openSurf源代码

    1.Computer Vision Datasets on the web http://www.cvpapers.com/datasets.html 2.Dataset Reference http ...

  9. 《循序渐进Oracle》部分笔记

    1.不要用户名/密码 直接/as sysdba 是操作系统认证方式,改变安全方式 sqlnet.ora 里SQLNET.AUTHENTICATION_SERVICES=(NTS)表示启动操作系统认证; ...

  10. My97 DatePicker

    支持日期以及时分秒的选择, 国人开发, 还不错! 官网: http://www.my97.net/