简体   繁体   中英

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.

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.

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.

How do I fix it?

如果您的图像显示为白色框,则只需使图像的背景透明即可。

it is problem of that picture.I dont know what reason it is. I make another one, works now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM