如何指定 UITabBar 中 UITabBarItem 之间的宽度、灵活空间和/或位置?
我正在开发一个项目,当时客户希望在某些视图的底部使用 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 UITabBarItem
s (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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你的想法是正确的。自定义
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 settitle
to an empty string and untickenabled
for the second and third view controller.