[英]How to change tab bar item' s icon?
I made a tab bar controller app in Xcode for the iPhone 4, but I am having difficult to change the icon of tab bar items. 我在Xcode中为iPhone 4创建了一个标签栏控制器应用程序,但是我很难更改标签栏项目的图标。
Here is my current code: 这是我当前的代码:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"abc", @"abc");
self.tabBarItem.image = [UIImage imageNamed:@"abc.png"];
}
return self;
}
I'm sure that abc.png
is under the group "images", and its size is 25*25px, and the file size is 4KB. 我确定abc.png
在“图像”组下,其大小为25 * 25px,文件大小为4KB。
if I change the picture to another one, it shows well. 如果我将图片更改为另一张,则显示效果很好。
It seems this is picture problem. 看来这是图片问题。 However, they are same size, made by Photoshop, saved as a png. 但是,它们的大小与Photoshop制作的相同,另存为png。
How do I fix it? 我如何解决它?
如果您的图像显示为白色框,则只需使图像的背景透明即可。
it is problem of that picture.I dont know what reason it is. 这是那张照片的问题。我不知道这是什么原因。 I make another one, works now. 我再做一个,现在工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.