自定义 UITabBarItem 的图标位置和标题(iphone sdk)

发布于 2024-08-08 21:12:01 字数 102 浏览 4 评论 0原文

我有一个 tabBar,我想自定义选项卡栏中的项目。我想阻止标题的显示(通过将标题设置为nil可以轻松实现),并将图标位置重置为中心垂直位置。有谁知道如何做到这一点?

谢谢。

I have a tabBar, and I want to customise the items in the tab bar. I want to prevent the display of the title (easily achieved by setting the title to nil), and reset the icon position to be in the central vertical position. Does anyone have any idea of how this can be done?

Thanks.

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

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

发布评论

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

评论(3

懵少女 2024-08-15 21:12:01

丑陋的黑客“解决方案”:将顶部图像插图设置为正值,将底部插图设置为相等但负值。

Ugly hacky "solution": set top image inset to positive value, bottom inset to equal but negative value.

心的憧憬 2024-08-15 21:12:01

正如 MM 所说,使用项目的 imageInsets 属性:

tabBarItem.imageInsets = UIEdgeInsetsMake(offset, 0, -offset, 0);

As MM says, use the item's imageInsets property:

tabBarItem.imageInsets = UIEdgeInsetsMake(offset, 0, -offset, 0);

失退 2024-08-15 21:12:01

您可以尝试使用 UIToolBar 而不是 UITabBar。 UIBarButtonItem 有方法 initWithCustomView。这比较复杂,但可能会正常工作。

You can try to use UIToolBar instead of UITabBar. UIBarButtonItem has method initWithCustomView. This is more complicated but may work properly.

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