导航控制器透明条样式不工作 [英] Navigation Controller Transparent Bar Style is not working

查看:124
本文介绍了导航控制器透明条样式不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是导航控制器,我的风格设置为:

I am using a navigation controller, and I have the style set to :

navController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

但是当我运行我的程序时,导航控制器看起来像是在白色背景的顶部,不是我的背景。当我推一个控制器,左或右,我所有的视图,当前的,移动到顶部的导航栏的大小。它在那里,我可以看到我的背景通过导航控制器栏。有任何想法吗?当我的barStyle设置为不透明,一切看起来很好。我正在考虑将我的视图框架设置为负的y值,但我认为应该有更优雅的方式。

But when I run my program, the navigation controller looks like it is on top of a white background, not my background. When I push a controller, left or right, all my view, the current one, shifts to the top exactly the size of the navigation bar. And it is there where I can see my background through the navigation controller bar. Any ideas? When my barStyle is set to opaque, everything looks fine. I was thinking on setting my view frame a negative 'y' value, but I think there should a more elegant way.

推荐答案

我相信UINavigationController假设你的控制器视图框架不包括导航栏下面的区域。

I believe the UINavigationController assumes that your controller view frames don't include the area beneath the navigation bar.

UIBarStyleBlackTranslucent更常用于UIToolbar,所以苹果可能没有使它很容易使用它与UINavigationBar。你可能需要放弃UINavigationController,或者开始黑客框架(仔细旋转),如果你想要可靠地渲染栏区域下。

UIBarStyleBlackTranslucent is more often used for UIToolbar, so Apple probably didn't make it easy to use it nicely with UINavigationBar. You'll probably need to abandon the UINavigationController, or start hacking the frames (careful with rotations), if you want to reliably render under the bar area.

此外,如果您的意图是在几秒钟后隐藏导航栏,如果您使其淡出(如照片应用)而不是尝试向上滑动,则会有很多更容易的时间苹果浏览器)。相信我一个......花了我很多时间来学习困难的方式。

Also, if your intention is to hide the navigation bar after a few seconds, you'll have a much easier time if you make it fade out (like the Photos app) instead of trying to slide it up (like Mobile Safari). Trust me on that one... that took me a lot of time to learn the hard way.

这篇关于导航控制器透明条样式不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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