4

I want to display only title for tabbar item without image. Is it possible? When I tried setting

let tabItem = UITabBarItem()
tabItem.title = "Tab1"
tabItem.selectedImage = nil
tabItem.image = nil
tabViewController?.tabBarItem = tabItem

I'm just getting a blank space which is tapable, but no title or image.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
JMS
  • 271
  • 4
  • 15
  • 1
    see if [this](http://stackoverflow.com/questions/11248457/is-it-possible-to-remove-the-images-in-the-uitabbaritem-and-aligned-vertically-t) can help u – Tj3n Mar 23 '17 at 11:05
  • Thank you. Your solution works perfectly. – JMS Mar 23 '17 at 12:03

2 Answers2

6

simplest way is remove the images from the tab bar and set the custom offset vertical.as shown in the image. or else follow the link that TJ3n priveded remove the images in the UITabBarItem and aligned vertically the title.

enter image description here

Community
  • 1
  • 1
adarshaU
  • 950
  • 1
  • 13
  • 31
2

In case you want it to be done programmatically:

tabItem.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -16)
AlexanderZ
  • 2,128
  • 3
  • 20
  • 24