
self.tabbarItem.image = [UIImage imagenamed:@"tab_img.png"];
这个tab_img.png由黑色,白色和清晰的颜色组成.但在应用程序中,黑白的图像全部变成灰色.我怎么能把这个灰色变成白色?
解决方法 在iOS7中,如果您使用IB,您可以将UITabbarController子类化,然后添加:+ (voID)initialize{ //the color for the text for unselected tabs [UITabbarItem.appearance setTitleTextAttributes:@{NSForegroundcolorAttributename : [UIcolor redcolor]} forState:UIControlStatenormal]; //the color for selected icon [[UITabbar appearance] setSelectedImageTintcolor:[UIcolor whitecolor]]; }- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) { for (UITabbarItem *tbi in self.tabbar.items) { tbi.image = [tbi.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; } }} 如果您创建项目手册,您必须在每个图标上设置UIImageRenderingModeAlwaysOriginal,并从初始化中添加代码.
总结以上是内存溢出为你收集整理的iphone – UITabBarItem图像颜色为灰色,原始图像为白色全部内容,希望文章能够帮你解决iphone – UITabBarItem图像颜色为灰色,原始图像为白色所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)