模态视图导航栏的位置 - iOS7 [英] Position of navigation bar for modal view - iOS7

查看:122
本文介绍了模态视图导航栏的位置 - iOS7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在导航控制器中,您可以按预期自动获得导航栏的正确颜色和位置。

In a navigation controller, you automatically get the correct colour and position of a navigation bar as expected.

喜欢这样

但在模态视图中,当您在导航栏中拖动时,您可以将其放置在顶部,这太靠近载体/电池信息。

But in modal view, when you drag in a navigation bar, you can position it right at the top, which is too close to the carrier / battery info.

所以你可以将它拖下来,猜测它与自动创建的位置匹配的距离,但是你有一个颜色差异。我试过更改IB中的状态栏设置,并没有什么区别。

So you can drag it down, guess how far so it matches the position of the automatically created one, but then you have a colour discrepancy. I have tried changing status bar settings in IB, doesnt make a difference.

是否有正确的方法可以解决这个问题,例如使模态视图看起来像自动生成的导航视图。

Is there a correct way to do overcome this, as in make a modal view look like the auto generated nav view.

谢谢

推荐答案

在iOS 7中克服这个问题的最佳方法是遵循新的 UIBarPositioningDelegate protocol。

The best way to overcome this in iOS 7 is by conforming to the new UIBarPositioningDelegate protocol.

您将NavigationBar的代表连接到视图控制器(通过故事板或代码将视图控制器设置为导航栏的代理并遵守该协议并实施该方法

You connect the delegate of your NavigationBar to your view controller (set your view controller as the delegate for the navigation bar either through storyboard or through code) and conform to that protocol and by implementing the method


- (UIBarPosition)positionForBar:(id< UIBarPositioning> )bar {
返回UIBarPositionTopAttached;
}

您可以删除视图控制器中的顶部间隙。您需要将条形放置在顶部边缘下方20个点

You can remove the top gap in the view controller. You need to place the bar 20 points below the top edge

这篇关于模态视图导航栏的位置 - iOS7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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