1

I have a UITabBarController like this:

UITabBarController

As you can see, the 'Discover' and 'Requests' titles are compressed by high amounts of kerning. They are also slightly clipped at the end of each item title. Is there any way to fix this?

P.S. The problem does not appear on iPhone 6 and 6+, only 5S and below.

Ben Lachman
  • 3,083
  • 1
  • 28
  • 44
demon9733
  • 1,054
  • 3
  • 13
  • 35
  • i hope this will help you http://stackoverflow.com/questions/15054056/size-of-the-tabbaritems-in-a-uitabbarcontroller – Dharma Nov 21 '14 at 15:08
  • I don't see this problem when I try your setup. It looks like the text is being confined to the width of the square image. Are you doing something to make that happen (my text extends beyond the edges of my image, a 20x20 square)? – rdelmar Nov 21 '14 at 17:39
  • @user1478, nothing helpful there – demon9733 Nov 21 '14 at 17:40
  • @rdelmar, icons are 30x30px. I'm doing nothing about these labels. I just set up image and title for my `UIViewController`-s – demon9733 Nov 21 '14 at 17:41
  • Are you creating these tab bar items in code or IB? – rdelmar Nov 21 '14 at 17:43
  • I can't reproduce your problem. For me, it works fine in code or in IB (Xcode 6.1). You should edit your question to show your code for creating the tab bar items. – rdelmar Nov 21 '14 at 17:51
  • 1
    @rdelmar, actually if forgot to mention that this `UITabBarController` is a tab of another `UITabBarController` with hidden tabbar. I need this to separate sign in/up part from actual app – demon9733 Nov 22 '14 at 12:00
  • That's probably not a good idea to have a tab bar controller embedded in another tab bar controller. You should rethink your UI (usually, sign in/sign up should be done in a modal view controller that you could present from the controller in the first tab of the main app). – rdelmar Nov 22 '14 at 15:42

2 Answers2

1

It seems like there is an issue with UITabBars where, if they deem their frame too small, they'll attempt to kern the item title labels to fit.

This issue with frame size can happen either from manually setting the frame of the UITabBar or possibly by having a larger number of items than will comfortably fit on screen (in your case 5).

In my experience with this issue, someone had erroneously set the frame of the UITabBar to CGRectZero so that, while hidden, it wouldn't effect layout geometry for a UIToolbar. Might you be manually editing the frame of one of the two tab bars you have?

Ben Lachman
  • 3,083
  • 1
  • 28
  • 44
0

I had this issue happen when I was trying to add a UITabBarController too soon. I was adding it as a child view controller of the main window.rootViewController in its viewDidLoad: method. However, the root view has not been properly initialized at this point yet, so the tab bar was using incorrect frame for calculations (as Ben Lachman alluded to). I solved it by adding a delay to initialize the images on the tab bar items, which in turn made the titles display with correct spacing.

anna
  • 2,723
  • 4
  • 28
  • 37