我想将图像放入我的UI中。作为UITabBarItem存在的Controllers
是UINavigationControllers
。当我试图把图像放在他们身上时,结果看起来不太好。我只获得了一半图像,图像没有显示颜色。在UITabBarController中显示图像 - 已更新
,我已经使用的具有png格式尺寸50X50图像3倍的图像。
在这里,我已经使用
self.custCareVC = [[CustomerCareViewController alloc] initWithNibName:@"CustomerCareViewController_iPhone" bundle:NULL];
self.POController = [[PurchaeOrderViewController alloc] initWithNibName:@"PurchaeOrderViewController_iPhone" bundle:NULL];
self.accAndContactsController = [[AccountsAndContactsViewController alloc] initWithNibName:@"AccountsAndContactsViewController_iPhone" bundle:NULL];
self.customerCareNavController = [[UINavigationController alloc] initWithRootViewController:self.custCareVC];
self.customerCareNavController.title = @"Customer Service";
self.purchaseOrderNavController = [[UINavigationController alloc] initWithRootViewController:self.POController];
self.purchaseOrderNavController.title = @"PO";
self.accAndContactsNavController = [[UINavigationController alloc] initWithRootViewController:self.accAndContactsController];
self.accAndContactsNavController.title = @"Accounts And Contacts";
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:self.customerCareNavController, self.accAndContactsNavController, self.purchaseOrderNavController, nil];
UIImage *selectedImage0 = [UIImage imageNamed:@"cust_serv_bw_selected.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"cust_serv_bw.png"];
UIImage *selectedImage1 = [UIImage imageNamed:@"contacts_bw_selected.png"];
UIImage *unselectedImage1 = [UIImage imageNamed:@"contacts_bw.png"];
UIImage *selectedImage2 = [UIImage imageNamed:@"po_bw_selected.png"];
UIImage *unselectedImage2 = [UIImage imageNamed:@"po_bw.png"];
UITabBar *tabBar = self.tabBarController.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
UITabBarItem *item2 = [tabBar.items objectAtIndex:2];
item0.image = unselectedImage0;
item0.selectedImage = selectedImage0;
item1.image = unselectedImage1;
item1.selectedImage = selectedImage1;
item2.image = unselectedImage2;
item2.selectedImage = selectedImage2;
self.tabBarController.selectedViewController = self.customerCareNavController;
我怎样才能纠正这种代码。这是为什么发生?
你是否使用了sufix @ 2x的高清图像? – Pull
没有..我没有使用@ 2X ..会试试这个,让你知道 – Shradha
我用@ 2x现在和尝试与30x30和50x50图像..但仍然无法工作 – Shradha