在导航控制器上按下时视图变暗 [英] Views getting darker when are pushed on navigation controller

查看:170
本文介绍了在导航控制器上按下时视图变暗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过segues在NavigationController上推送ViewControllers。我有自己的子类NavigationController,它在索引0处插入了 UIImageView - 它是我整个应用程序的背景。

I'm pushing ViewControllers on NavigationController by segues. I have my own subclassed NavigationController which has inserted UIImageView at index 0 - it's a background for my entire application.

问题是我可以看到当新的视图控制器从右侧进入屏幕时,在开始时它就像有一些浅黑色覆盖,当在 viewDidApear 被调用。

The problem is that I can see that when new view controller is coming to the screen from the right side, in the beginning it's like having some light dark overlay which is disappearing when just after viewDidApear is called.

每个视图控制器都有一个 self.view.backgroundColor = [UIColor clearColor]
如果我改变它,一切都很好。
也许我应该以另一种方式设置申请背景?
如果没有,如何避免这种黑暗效应?

Every view controller has a self.view.backgroundColor = [UIColor clearColor]. If i change it for while, everything is fine. Maybe i should set background of application in another way? And if not, how to avoid this darkling effect?

这里有你的屏幕截图效果:
http://tinypic.com/r/34j9ffs/8

Here you have screen capture with this effect: http://tinypic.com/r/34j9ffs/8

推荐答案

这是因为iOS 7中的标准 UINavigationController 推送动画。当一个新的VC被推入堆栈时,它会覆盖在之前的VC之上,在它下面有一个轻微的阴影。因此,当您推动具有清晰背景的viewControllers时,您会在转换发生时看到阴影。

It's because of the standard UINavigationController push animation in iOS 7. When a new VC is pushed onto the stack, it overlays itself on top of the previous VC, with a slight shadow underneath it. As such, when you push your viewControllers which have clear backgrounds, you see through to the shadow when the transition takes place.

有几种可能的解决方案:

There are a couple of possible solutions:


  • 在viewControllers上设置背景颜色(由于您的全局背景图像,可能不适合您)。最简单的解决方案,但需要更改您的设计。

  • 使用新的iOS 7 API实现您自己的转换。请参阅此处的示例 Big Nerd Ranch 。如果你想保留你的背景图像,这真的是你的问题的正确解决方案。

  • 添加 UINavigationController 类别来添加一个更简单的'复古'推送和流行动画,根据这个答案。这是一个快速而又狡猾的解决方案。

  • Set a background colour on your viewControllers (probably not an option for you because of your global background image). The simplest solution, but would require a change to your design.
  • Implement your own transition using the new iOS 7 APIs. See an example here and an article from Big Nerd Ranch here. This is really the 'proper' solution to your problem if you want to keep your background image.
  • Add a UINavigationController category to add a simpler 'retro' push and pop animation, as per this answer. This is more of a quick and hacky solution.

这篇关于在导航控制器上按下时视图变暗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆