我是新手到iphone的开发,我需要把一个自定义的图像图标在标签栏.But它只显示默认的颜色(黑色和蓝色) .Help我来克服这个bug朋友…?
发布于 2012-12-21 21:40:01
在应用程序中添加图像,
并查看附加的图像
发布于 2012-12-21 18:17:26
在viewDidLoad中使用此代码
UIImage *selectedImage0 = [UIImage imageNamed:@"selected.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"unselected.png"];
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
发布于 2014-06-16 01:04:43
您可以将以下代码片段用于ios7:
UIImage *iconBoxOffice = [UIImage imageNamed:@"box-office.png"];
UIImage *selectedIconBoxOffice = [UIImage imageNamed:@"selected-box-office.png"];
UIImage *iconDvds = [UIImage imageNamed:@"dvds.png"];
UIImage *selectedIconDvds = [UIImage imageNamed:@"dvds.png"];
UITabBar *tabBar = self.tabBarController.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
[item0 initWithTitle:@"Box Office" image:iconBoxOffice selectedImage:selectedIconBoxOffice];
[item1 initWithTitle:@"Dvds" image:iconDvds selectedImage:selectedIconDvds];
如果你有更多的标签,你可以继续添加更多的项目。*不要忘记将图像添加到您的项目中*这是以编程方式完成的,而不是使用故事板
https://stackoverflow.com/questions/13988162
复制相似问题