Swift Tabbar无法正确显示

发布于 2025-01-22 22:30:45 字数 978 浏览 4 评论 0原文

在Xcode中,我有此应用程序使用TabBariTem。有5个项目,偶尔我在特定页面上时会得到Tabbaritems的奇怪覆盖(请参阅图片)。我偶尔说,因为它并不总是这样做,但仍然很频繁。不确定这只是Tabbaritem的限制还是我有错误。

这就是应该的外观:

这是不应该看起来的方式,而是这样做:

正如您在第二张图像中看到的那样,塔巴尔被叠加到其他文本上,而不是在其后面消失。奇怪的是,每个选项卡的行为不同。

我可以解决这个问题,

        if #available(iOS 15.0, *) {
            let appearance = UITabBarAppearance()
            appearance.configureWithOpaqueBackground()
            appearance.backgroundColor = .black
            UITabBar.appearance().standardAppearance = appearance
            UITabBar.appearance().scrollEdgeAppearance = UITabBar.appearance().standardAppearance
        }

但需要一个适用于iOS 11+的修复程序

In Xcode I have this app that uses tabBarItem. There are 5 items and occasionally when I'm on a specific page I get this weird overlay of the tabBarItems (see pictures). I say occasionally, because it does not do it always but it is still very frequent. Not sure if it is just a limitation with tabBarItem or if I have a bug.

This is how it SHOULD look:
enter image description here

This is how it SHOULD NOT look, but does:
enter image description here

As you can see in the second image the tabBar is being overlayed onto the other text rather than disappearing behind it. It's odd that it behaves differently for each tab.

I can fix the issue with

        if #available(iOS 15.0, *) {
            let appearance = UITabBarAppearance()
            appearance.configureWithOpaqueBackground()
            appearance.backgroundColor = .black
            UITabBar.appearance().standardAppearance = appearance
            UITabBar.appearance().scrollEdgeAppearance = UITabBar.appearance().standardAppearance
        }

But need a fix that would work for IOS 11+

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

糖果控 2025-01-29 22:30:45
        UITabBar.appearance().isTranslucent = false
        UITabBar.appearance().backgroundColor = .black
        UITabBar.appearance().isTranslucent = false
        UITabBar.appearance().backgroundColor = .black
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文