0
我已將子類型UITabBarController
爲了自定義tabBarItem
標題和圖像。使用下面的代碼,標題顯示正確,但xbutton.png
未顯示。我如何正確定製圖像?自定義tabBarItem圖像不出現
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UITabBar *tabBar = self.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
tabBarItem1.title = @"Buy";
tabBarItem2.title = @"MatchCenter";
tabBarItem1.selectedImage = [UIImage imageNamed:@"xbutton.png"];
tabBarItem2.selectedImage = [UIImage imageNamed:@"xbutton.png"];
}
是的,他們是灰度。 – Ghobs 2014-08-28 20:58:25
還要確保它們是png,然後在你的編輯器中打開並保存它們。當你嘗試tabBarItem1 setImage會發生什麼:[UIImage imageName:@「xbutton.png」] 也是你的圖像作爲一個文件添加到Xcode或是images.xcassets的一部分? 如果你刪除.png,它會工作嗎? – 2014-08-28 23:50:16