2012-09-25 14 views

Odpowiedz

34

Gotowy!

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

+2

Staram samo, ale jej nie działa. Czy my też musimy robić cokolwiek innego? – Devang

+1

Nie, to wszystko. Gdzie to wkładasz? –

+0

Dlaczego (0, -10)? Nie rozumiem ... Czy możesz mi wyjaśnić? – LKM

3

Dodatek, jeśli ustawisz wielo viewControllers w TabBarController, należy użyć następujących:

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

szybkiej aktualizacji.

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 
    } 

// Na przykład

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 
window?.makeKeyAndVisible() 
Powiązane problemy