ij_*_*ij_ 11 iphone objective-c ipad ios
我使用以下代码为我创建图像 UITabBarItem
self.tabBarItem.image = [UIImage imageNamed:@"tab_img.png"];
Run Code Online (Sandbox Code Playgroud)
tab_img.png由黑色,白色和清晰的颜色组成.但在应用程序中,黑白图像的所有部分都变为灰色.我怎么能把这个灰色变成白色?
Cor*_*ian 34
在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];
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果您手动创建项目,则必须在每个图标上设置UIImageRenderingModeAlwaysOriginal并添加初始化的代码.
fib*_*chi 10
设置选定和未选择的图像.
[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"mehr_icon"] withFinishedUnselectedImage:[UIImage imageNamed:@"mehr_icon"]];
Run Code Online (Sandbox Code Playgroud)
UITabBarItems 的图像应该只是 alpha 通道!不过,不透明部分只会显示灰色(如果选择蓝色)!
看看:http ://devinsheaven.com/creating-uitabbar-uitoolbar-icons-in-adobe-illustrator/
归档时间: |
|
查看次数: |
18310 次 |
最近记录: |