ios tabbar put text in the middle when no image

3 Solutions Collect From Internet About “ios tabbar put text in the middle when no image”

Got it!

[tab.tabBarItem setTitlePositionAdjustment:UIOffsetMake(0, -10)]

A supplement, if you set multi viewControllers in tabBarController, you should use the following:

for (UITabBarItem* item in tabBarController.tabBar.items)
    [item setTitlePositionAdjustment:UIOffsetMake(0, -10)];

swift update.

func tabBarItem(title: String, imageName: String, selectedImageName: String, tagIndex: Int) -> UITabBarItem {
        let item = UITabBarItem(title: title,
                                image: UIImage(named: imageName),
                                selectedImage: UIImage(named: selectedImageName))
        item.titlePositionAdjustment = UIOffset(horizontal:0, vertical:-10)
        item.tag = tagIndex
        return item

// For example

let window = UIWindow.window()
let vc = UIViewController()
vc.tabBarItem = tabBarItem(title: "More", imageName: "icon_more", selectedImageName: "icon_more", tagIndex: 1)

let mainTBC = UITabBarController()
    mainTBC.viewControllers = [vc]
 window?.rootViewController = mainTBC