iOS 7 |导航栏/工具栏按钮非常靠近状态栏 [英] iOS 7 | Navigation bar / Toolbar buttons very close to status bar

查看:125
本文介绍了iOS 7 |导航栏/工具栏按钮非常靠近状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将导航栏或工具栏(情节提要板)拖动到视图控制器时出现问题。

I have a problem when dragging a navigation bar or toolbar (storyboard) to my view controller.

UINavigationBar:

UINavigationBar:

正如您所见在上面的图片中,右键几乎与状态栏重叠。

As you can see in the image above, the right button is almost overlapping the status bar.

使用UIToolbar它会发生相同的事情:

With a UIToolbar it happens the same:

此视图控制器旨在要用作Modal,这就是我没有使用UINavigationController的原因。

This view controllers are intended to be used as a Modal, that's the reason I'm not using a UINavigationController.

在另一部分我使用UINavigationController它看起来像我期望的那样:

In another section I use a UINavigationController and it appears as I expect:

如何在不重叠状态栏的情况下将UINavigationBar / UIToolbar拖动到视图控制器?

推荐答案

导航条形图或工具栏必须位于(0, viewController.topLayoutGuide.length ),条形定位为 UIBarPositionTopAttached 。您应该将导航栏或工具栏的委托设置为视图控制器,然后返回 UIBarPositionTopAttached 。如果定位正确,您将在第三张图片中得到结果。

The navigation bars or toolbars have to be at (0, viewController.topLayoutGuide.length) with bar positioning of UIBarPositionTopAttached. You should set the delegate of your navigation bar or your toolbar to your view controller, and return UIBarPositionTopAttached. If positioned correctly, you will have the result in your third image.

此处提供更多信息:
https://developer.apple.com/documentation/uikit/uibarpositioningdelegate?language=objc

这篇关于iOS 7 |导航栏/工具栏按钮非常靠近状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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