将顶部栏添加到所有视图都可见的iOS应用程序

问题描述:

在标签栏iOS应用程序中添加顶部栏(视图)的最佳方法是什么,它总是保留在所有视图之上,而不管选择哪个标签如下图所示?

What is the best way to add a topbar(View) in a tabbar iOS application that always remain on top of all the views, irrespective of which tab is selected like the image below?

我会使用UIViewControllerContainment。看看

I would use UIViewControllerContainment. Take a look at

https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html

我的方式设置它有一个UIViewController有两个ContainerViews。一个ContainerView将包含UITabBarController,另一个将具有顶部栏的UIViewController。

The way I'd set it up is have a UIViewController that has two ContainerViews. One ContainerView will have the UITabBarController in it and the other would have the UIViewController for the top bar.

这是我在UIStoryboard中做的

Here is what I did in a UIStoryboard