在TabBArController中自定义tabBarItems的外观

时间:2014-01-30 08:57:44

标签: ios uitabbarcontroller

在我的申请中,我使用的是UITabBarController。但是,我需要自定义UITabBarItems的外观。

目前,我的屏幕看起来像这样:

enter image description here

我想增加标签之间的距离,而中间标签有更大的文字,因此标签看起来非常拥挤。另外,我想在标签之间添加一个分隔符。

以下是代码:

customerCareNavController = [[UINavigationController alloc] initWithRootViewController:custCareVC];
    customerCareNavController.title = @"Inquiry";

    purchaseOrderNavController = [[UINavigationController alloc] initWithRootViewController:POController];
    purchaseOrderNavController.title = @"Purchase Order";

    accAndContactsNavController = [[UINavigationController alloc] initWithRootViewController:accAndContactsController];
    accAndContactsNavController.title = @"Accounts And Contacts";

    tabBarController = [[UITabBarController alloc] init];

    tabBarController.viewControllers = [NSArray arrayWithObjects:customerCareNavController,accAndContactsNavController,purchaseOrderNavController, nil];

[(UITabBarItem*)[tabBarController.tabBar.items objectAtIndex:0] setImage:[UIImage imageNamed:@"Customer_Service.png"]];


        [(UITabBarItem*)[tabBarController.tabBar.items objectAtIndex:1] setImage:[UIImage imageNamed:@"Acc_Cont.png"]];


        [(UITabBarItem*)[tabBarController.tabBar.items objectAtIndex:2] setImage:[UIImage imageNamed:@"PO.png"]];

1 个答案:

答案 0 :(得分:0)

设置tabBarItem,如

UITabBarItem* ClientSupportTabBarItem = [[UITabBarItem alloc] init];
[ClientSupportTabBarItem  setFinishedSelectedImage: [UIImage imageNamed: @"btnTabItem-active.png"] withFinishedUnselectedImage: [UIImage imageNamed: @"btnTabItemNormal.png"]];
ClientSupportTabBarItem.title = @"Inquiry";
[customerCareNavController setTabBarItem: ClientSupportTabBarItem];