Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
400 views
in Technique[技术] by (71.8m points)

uinavigationbar - iOS 7 | Navigation bar / Toolbar buttons very close to status bar

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.

With a UIToolbar it happens the same:

UIToolbar

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

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

UINavigationController

How can I drag a UINavigationBar / UIToolbar to a view controller without overlapping the status bar?

question from:https://stackoverflow.com/questions/18901753/ios-7-navigation-bar-toolbar-buttons-very-close-to-status-bar

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

More information here: https://developer.apple.com/documentation/uikit/uibarpositioningdelegate?language=objc


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...