1

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.

MM.
  • 4,224
  • 5
  • 37
  • 74

3 Answers3

10

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

MM.
  • 4,224
  • 5
  • 37
  • 74
3

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

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

Malloc
  • 15,434
  • 34
  • 105
  • 192
JimmyB
  • 326
  • 3
  • 12
0

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

Morion
  • 10,495
  • 1
  • 24
  • 33
  • Yeah, I've been trying my best to avoid this as the code is already structured around a tab bar. It would be cleaner to user a UIToolBar though... – MM. Oct 29 '09 at 14:09