0

Is there any way to create a tab bar in iOS with 3 tab bar items having these positions:

Tab1 - margin left equals 0;

Tab2 - centered horizontally;

Tab3: margin right equals 0 ?

Image

I tried UITabBarItemPositioning.Fill and creating a custom UITabBar in order to find some methods/properties to override, but I didn't find anything useful.

Madalin Sisu
  • 92
  • 1
  • 12

1 Answers1

0

Use TitlePositionAdjustment in UITabBarItem.

You can set the horizontal margin or vertical margin.

Since UITabbarItem is not a UIView , We can't access its subview and can't get the frame from it , so we have to set different fixed values on different devices.

Ugly but it works:

nfloat TitlePositionAdjustment = 0;
if (IPhone4) {
    TitlePositionAdjustment = xx;
}
else if (IPhone5)
{
    TitlePositionAdjustment = xx;
}
//xxx and so on..

tab.TitlePositionAdjustment = new UIOffset(TitlePositionAdjustment, 0);

If you don't want this solution, I think you need to create custom view to simulate UITabBar.

enter image description here

ColeX
  • 14,062
  • 5
  • 43
  • 240