看效果图:

用例如以下代码,想弹出一个模态窗体,设置它的背景透明度为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. Android 结合实例学会AsyncTask的使用方法

    AsyncTask运行时经过四个步骤,运行四个方法:           1.onPreExecute(),执行在UI线程,能够设置或改动UI控件,如显示一个进度条           2.doInB ...

  2. python语言学习7——数据类型和变量

    整数 python可以处理任意大小的整数,包括负整数,在程序中的表示方法和数学上的写法一样 计算机由于使用二进制,有时候采用十六进制表示整数比较方便,十六进制数用0x前缀 浮点数 简单的小数就直接用小 ...

  3. POJ训练计划3080_Blue Jeans(串处理/暴力)

    Blue Jeans Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11542   Accepted: 4962 Descr ...

  4. 找呀志_通过开源框架引AsyncHttpClient上传文件

    一个.步骤: 1.加入权限(接入网络和可写) 2.获取上传文件的路径和推断是空的 3.如果为空.创建一个异步请求对象 4.创建上传文件路径 5.跑post请求(指定url路径.封装上传參数.新建Asy ...

  5. Redis集群明细文档(转)

    相信很多用过Redis的同学都知道,Redis目前版本是没有提供集群功能的,只能单打独斗.如果要实现多台Redis同时提供服务只能通过客户端自身去实现.目前根据文档已经看到Redis正在开发集群功能, ...

  6. jar包有嵌套的jar的打包成jar的方法

    1.先写一个类,将其打包成jar包. 代码如下: package com.wjy.jar; public class GetUserName { public String getUserName() ...

  7. vmware无法链接U盘:vm-->removeable devices.

    vmware无法链接U盘:vm-->removeable devices.

  8. Linux下忘记rootpassword怎么办?

    1.首先确认server出于安全的状态.也就是没有人可以随意地连接MySQL数据库. 由于在又一次设置MySQL的rootpassword的期间,MySQL数据库全然出于没有password保护的  ...

  9. ocx控件手动修改clsid的方法

    替换掉工程的两个地方:IDL文件和CTRL文件. IMPLEMENT_OLECREATE_EX(CMultiwndCtrl, "MULTIWND.MultiwndCtrl.1", ...

  10. Python学习入门基础教程(learning Python)--3.2 if-else分支语句

    if-else分支语句结构的特点是当conditon条件满足时,执行if下的语句块,当condition条件不满足时执行else下的语句块,也就是说根据条件来控制让某些语句执行,某些语句不被执行. i ...