开发者

Customizing icon position and title of UITabBarItem's (iphone sdk)

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 id开发者_StackOverflowea of how this can be done?

Thanks.


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


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

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜