iOS 7 UINavigationBar - UIView布局问题 [英] iOS 7 UINavigationBar - UIView layout issue

查看:175
本文介绍了iOS 7 UINavigationBar - UIView布局问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

布局有问题。

以下是它在iOS6上的表现:

Here is how it looks right on iOS6:

以下是iOS7的外观:

Here is how looks on iOS7:

但没关系。
Apple的iOS7中描述的一样TransitionGuide
我在写了一个笔画 - (无效)viewDidLoad

        self.edgesForExtendedLayout = UIRectEdgeNone;

现在它看起来像这样:

有任何建议吗?我的布局有什么问题?
我想要坚实的蓝色UINavigationBar。并且不知道为什么这个的顶部是透明的。
有任何想法,为什么它看起来如此奇怪?我该如何解决这个问题?

Any suggestions? What can be wrong with my layouts? I want solid blue UINavigationBar. And have no idea, why the top of this is transparent. Have any ideas, why it looks so strange? How can I fix this?

推荐答案

尝试 navigationBar.translucent = NO;

默认情况下 YES

来自 UINavigationBar 文档:


iOS 7上的新行为。默认为YES。您可以通过将属性设置为NO来强制使用不透明的
背景。如果导航栏具有
自定义背景图像,则默认值是从图像的alpha
值推断出的,如果它具有alpha< 1.0如果
将setTranslucent:YES发送到具有不透明自定义背景
图像的条形图,它将对图像应用小于1.0的系统不透明度。如果
你发送setTranslucent:NO给一个半透明的自定义
背景图像的条形图,它将为图像
提供一个不透明的背景,使用条形图的barTintColor(如果已定义),或黑色为UIBarStyleBlack $ b $如果barTintColor为零,则为UIBarStyleDefault的b或白色。

New behavior on iOS 7. Default is YES. You may force an opaque background by setting the property to NO. If the navigation bar has a custom background image, the default is inferred from the alpha values of the image—YES if it has any pixel with alpha < 1.0 If you send setTranslucent:YES to a bar with an opaque custom background image it will apply a system opacity less than 1.0 to the image. If you send setTranslucent:NO to a bar with a translucent custom background image it will provide an opaque background for the image using the bar's barTintColor if defined, or black for UIBarStyleBlack or white for UIBarStyleDefault if barTintColor is nil.

这篇关于iOS 7 UINavigationBar - UIView布局问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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