2012-09-25 16 views

cevap

34

Anladım!

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

için

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 } 

// Ben de aynı şeyi çalışıyorum, ancak onun çalışmıyor. Başka bir şey yapmak zorunda mıyız? – Devang

+1

Hayır, bu kadar. Onu nereye koyuyorsun? –

+0

Neden (0, -10)? Anlayamıyorum ... Beni anlatabilir misin? Https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitDataTypesReference/index.html#//apple_ref/c/tdef/UIOffset uIOffset belgesine bağlı olarak – LKM

3

bir ek, aşağıdaki kullanmalıdır. Örneğin

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() 
0

hızlı güncelleme: Eğer TabBarController çoklu viewControllers ayarlarsanız

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

İlgili konular