看效果图:

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

    static function Instantiate (original : Object, position : Vector3, rotation : Quaternion) : Object ...

  2. 【WinRT】【译】【加工】在 XAML 中制作圆形图片

    原文:[WinRT][译][加工]在 XAML 中制作圆形图片 原文地址:http://timheuer.com/blog/archive/2015/05/06/making-circular-ima ...

  3. jquery.ui.accordion的修改(支持展开多个)

    原文:jquery.ui.accordion的修改(支持展开多个) 背景:原jquery.ui.accordion插件,最多只能展开一个,不能展开多个,后来在网上找到了一个基于它的一个修改版(http ...

  4. Loser应该知道的6个残酷人生事实(血泪翻译)

    Loser应该知道的6个残酷人生事实(血泪翻译) - Acfun - 天下漫友是一家 Loser应该知道的6个残酷人生事实(血泪翻译)

  5. C++ Primer 学习笔记_61_重载操作符与转换 --自增/自减操作符

    重载操作符与转换 --自增/自减操作符 引言: 自增,自减操作符常常由诸如迭代器这种类实现,这种类提供相似于指针的行为来訪问序列中的元素.比如,能够定义一个类,该类指向一个数组并为该数组中的元素提供訪 ...

  6. 《深入理解OSGi:Equinox原理、应用与最佳实践》笔记_1_运行最简单的bundlehelloworld

    <深入理解OSGi:Equinox原理.应用与最佳实践>笔记_1_运行最简单的bundlehelloworld 买了周大大的OSGI的书看 先前完全没有基础 就靠这本书看看学学 顺便记一些 ...

  7. js封装好的模仿qq消息弹窗代码

    在我们的日常开发中,或者生活中.常常须要用到弹出窗.这里我们就用js模拟一下qq消息一样的弹出窗. 直接贴代码: <!DOCTYPE html PUBLIC "-//W3C//DTD ...

  8. Python的Tkinter去除边框

    from Tkinter import * class Application(Frame): def __init__(self,master=None, *args, **kwargs): Fra ...

  9. 第1次实验——NPC问题(回溯算法、聚类分析)

    题目:八皇后问题,是一个古老而著名的问题,是回溯算法的典型案例.该问题是国际西洋棋棋手马克斯·贝瑟尔于1848年提出:在8X8格的国际象棋上摆放八个皇后,使其不能互相攻击,即随意两个皇后都不能处于同一 ...

  10. Json,Gson,FastJson解析笔记

    Json,Gson,FastJson解析笔记 1.将JavaBean转换成Json对象: public static String CreatJsonFromObject(Object key,Obj ...