How to create a view above navigation bar or other

2019-09-12 03:52发布

I would like to have a view above the navigation bar, or above any screen content if there isn't a navigation bar on that screen, so that it essentially reduces the height of everything else and doesn't cover any content. I also would like this view allow interaction (i.e. if its tapped, it would do something).

I have tried UIApplication.sharedApplication().keyWindow?.addSubview(view) but that just overlays the view.

Here is a visualization: View above navigation bar.

标签: ios swift uiview
1条回答
迷人小祖宗
2楼-- · 2019-09-12 04:19

Don't think of it in terms of above, think of it as beside - a sibling view.

So, create your own root view controller with that view and a container view below it, then add your 'normal' root navigation controller (or whatever) as a child view controller into the container view.

查看更多
登录 后发表回答