UItabBarItem高亮状态图
我希望能够在选择 UITabBarItem 时更改其上突出显示的状态图像?是否可以子类化并访问它?或者我需要滚动自己的导航代码吗?
->开始编辑 我之前没有明确说明我在寻找什么。我正在寻找设备添加到 UITabBar 的选定状态/图像的半透明白色覆盖参考。看图片! http://solomon71.com/images/UITabBarItem.png
I'd like to be able to change the highlighted state image on an UITabBarItem when it is selected? Is it possible to subclass and access this? or do I need to roll my own navigation code?
-> start edit
I didn't articulate what I was looking for earlier. I am looking for the semi-transparent white overlay reference that the device adds to the selected state/image of the UITabBar. See image! http://solomon71.com/images/UITabBarItem.png
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有记录或支持的方法来设置您自己的突出显示图像。话虽如此,在 2.2 中,您可以通过子类化 UITabBarItem 并实现
-[UIImage *)selectedImage
来做到这一点。严格来说,您没有调用私有 API,因为 selectedImage 不是保留的方法名称(实际上是一个供某人自己使用的相当合理的名称)。话虽如此,我确信这不是有意的,并且它可能在未来的版本中随时中断。如果这在 3.x 中已经被破坏了,我也不会感到震惊(我从未发布过任何这样做的东西,只是为客户进行了实验)。
There is no documented or supported way to set your own highlighted image. Having said that, in 2.2 you could do it by subclassing UITabBarItem and implementing
-[UIImage *)selectedImage
.Strictly speaking you are not calling private API, since selectedImage is not a reserved method name (and is actually a fairly reasonable name for someone to use themselves). Having said that, I am sure this is not intended and it could break at any time in a future release. It wouldn't shock me if this was already broken in 3.x (I never shipped anything that did this, just experimented with it for a client).
试试这个。
我已经更改了选定的 tabbatitem 图像,例如 -
在选项卡控制器委托方法中,
您可以通过此更改图像。
或者您可以直接在视图控制器 init(或 ViewWillAppear) 方法中使用,例如
try this one.
I have change the selected tabbatitem image like -
in tabbar controller delegate method
through this you can change your image.
Or you can use directly in your view controllers init(or ViewWillAppear) method, like