UITabBarController定制
在我们的原生iPad应用程序中,我们需要对标签栏进行一些自定义,即:
- 我们希望标签栏的高度为54px,
- 选择时标签栏图标的突出显示颜色需要为黄色
- 必须有标签栏顶部边缘有轻微的阴影。
Apple 的文档指出 UITabBarController 不应该被子类化。 如果我无法子类化 UITabBarController,请告知实现上述自定义的最佳方法是什么。
谢谢。
In our native iPad app, we need a few customizations to be done to the tab bar namely:
- We want the height of the tab bar to be 54px,
- The highlight color of the tab bar icons when selected needs to be yellow
- There has to be a slight shadow at the top edge of the tab bar.
Apple's documentation states that UITabBarController is not meant to be subclassed.
Please advise what would be the best way to achieve the above customization if I cannot subclass UITabBarController.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以对它进行子类化,只是苹果不鼓励它,因为肯定有人会搞砸/彻底改变功能。如果你只是为其设置主题并且看起来并不难看,那么一切都应该没问题。
如果他们确实拒绝它,您可以转到默认的 UITabBar 并附带它。
您可能还想查看 Three20
You can subclass it, just apple discourages it because someone is bound to screw it up/change the functionality drastically. If you're just theming it and it doesn't look ugly, things should be fine.
If they do reject it, you can just go to the default UITabBar and ship with that.
You may also want to look at Three20
我认为最好的选择是使用基于 UIViewController 的自定义解决方案。
我确实编写了一个兼容 iOS 7+ 的简单 UITabBar+UITabBarController 替代品,您可以使用它作为起点。它可以支持任意数量的选项卡,并使用自动布局来构建其视图层次结构。查看 NGTabBar。
I think your best option would be to use a custom solution based on
UIViewController
.I did write an iOS 7+ compatible simple UITabBar+UITabBarController replacement, you could use it as a starting point. It can support any number of tabs and that uses Auto Layout to build it's view hierarchy. Check out NGTabBar.