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

标签 ios objective-c ios7 uibutton uinavigationitem

我希望我的 UITabBarController 中的中间按钮具有与其他按钮不同的颜色,例如 Instagram。有人有什么建议吗?

最佳答案

您应该为每个 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];

希望这有帮助:)

干杯

关于ios - 如何更改 iOS 7 中的中心标签栏按钮颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25231553/

相关文章:

ios - ScrollsToTop 在 iOS 7 上不起作用

android - iOS 3des 的加密与 android 和 .net 不同

php - 如何创建网站 API

ios - 由于没有系统应用程序而终止?

ios - 更改条形色调颜色使模糊区域变为黑色和白色

ios - 在 iOS 7 中完成某些操作后显示文本警报

iOS 7 获取所有可用的音频设备(蓝牙、耳机、扬声器、电话)

ios - 为什么我不能捕获这个 Swift 异常?

objective-c - IOS 中的圆形进度条

ios - 使用UIWebview禁用IOS应用程序中的缓存