如何在iOS 7中更改中心标签栏按钮颜色?

时间:2014-08-10 18:07:28

标签: ios objective-c ios7 uibutton uinavigationitem

我希望UITabBarController中的中间按钮与其他按钮颜色不同,例如Instagram。有没有人有任何建议?

1 个答案:

答案 0 :(得分:1)

您应该为每个tabBarItem图像设置不同的颜色而不是颜色(如果您希望它像Instagram一样)

以下是一个示例:

UITabBarItem *tabBarItem = [yourTabBarController.tabBar.items objectAtIndex:2]; //set objectAtIndex you want (For Instagram its 2)

UIImage *unselectedImage = [UIImage imageNamed:@"unselected-imagename"]; //set unselected image
UIImage *selectedImage = [UIImage imageNamed:@"selected-imagename"]; //set selected image

[tabBarItem setImage: [unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[tabBarItem setSelectedImage: selectedImage];

希望这会有所帮助:)

干杯