如何指定 UITabBar 中 UITabBarItem 之间的宽度、灵活空间和/或位置?

发布于 2024-10-06 00:02:24 字数 268 浏览 0 评论 0原文

我正在开发一个项目,当时客户希望在某些视图的底部使用 UITabBar 类似的工具栏(图标和标题)。

选项卡栏需要在左侧有 1 个项目、空白区域,然后在右侧有 2 个项目。

我是否必须使用 2 个额外的 UITabBarItem(并将它们放在第二个和第三个位置)并隐藏和禁用它们才能完成此操作,或者是否有更直接的解决方案?

我不想为此使用 UIToolBar ,因为自定义其高度是一种痛苦,并且在某些情况下会导致意外行为(特别是当使用模态视图控制器时)。

I am working on a project when client wants UITabBar lookalike toolbar (icons and titles) at the bottom of some views.

The tab bar needs to have 1 item at the left, empty space, and then 2 items at the right.

Do I have to use 2 extra UITabBarItems (and put them at second and third position) and hide and disable them to accomplish this, or is there a more straightforward solution?

I would like to not to use UIToolBar for this as customizing its height is a pain and causes unexpected behavior in some cases (especially when one uses modal view controllers).

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

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

发布评论

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

评论(1

_失温 2024-10-13 00:02:24

我认为你的想法是正确的。自定义 UITabBar 来做一些不寻常的事情通常非常困难,最好自己编写。但就您而言,您应该能够按照您的建议进行。一种方法是直接在 IB 中添加视图控制器,然后将 title 设置为空字符串,并取消选中第二个和第三个视图控制器的 enabled

I think you have the right idea. Customizing UITabBar to do stuff out of the ordinary is often quite hard and it is better to just write your own. But in your case you should be able to just as you proposed. One way would be to add the view controllers directly in IB and then set title to an empty string and untick enabled for the second and third view controller.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文