使用 UITabBarController 时覆盖整个屏幕的视图?
我想在 UITabBarController 设置中在整个屏幕上覆盖 HUD 样式的透明图形。执行此操作的按钮位于第一个选项卡的屏幕(FirstViewController)中,并且覆盖层也应该覆盖选项卡......这可能吗?
I want to overlay a HUD-style transparent graphic over the entire screen in a UITabBarController setup. The button to do this is in the first tab's screen (FirstViewController), and the overlay should also cover the tabs... is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以将新视图直接附加到窗口。
You could attach your new view to your window directly.
Henrik P. Hessel 的上述解决方案很好,但该解决方案有一个问题。 elsurudo 在答案下面的评论中已经提到了这个问题。
我遇到了同样的问题,尝试了不同的方法,并找到了一个解决方案来消除该问题。
解决方案很简单。您可以将该
myNewView
添加到UITabBarController
的视图中。希望它对未来的访客有用。
The above solution by Henrik P. Hessel is Good but there is one problem with that solution. The problem is already mentioned by elsurudo in the comment below the Answer.
I faced the same problem and I tried different things and I got one solution to eliminate that problem.
The solution is simple. You can add that
myNewView
toUITabBarController
's view.Hope, it will be useful for future visitors.
这可能与上面提到的
[[UIApplication sharedApplication] keyWindow]
相同。但我喜欢通过当前的观点来引用它。This might be the same as the
[[UIApplication sharedApplication] keyWindow]
mentioned above. But I like referencing it through the current view.受到 rdelmar 对另一个问题的回答的启发,我建议将 UITabBarController 放在 Container View other
ViewController
中。然后将你的HUD添加到ViewController
视图上。Inspired by rdelmar's answer to another question, I recommend putting your UITabBarController in Container View other
ViewController
. Then add your hud ontoViewController
view.我真的很喜欢 Chase Robert 在这里写的内容,所以我想也提供 Swift 3. 版本:
我也添加了条件,这样如果没有窗口,你就不会崩溃。
I really liked what Chase Robert had written here, so I thought to provide the Swift 3. version as well:
I added the condition as well, so you don't get a crash if there's no windows.