我正在尝试将自定义图像添加到tabview控制器,它对我来说工作正常这是我正在使用的代码
[[AppDelegate.Tabctrl.tabBar.items objectAtIndex:0] setFinishedSelectedImage:[UIImage imageNamed:@"Home-Select.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"Home.png"]];
[[AppDelegate.Tabctrl.tabBar.items objectAtIndex:1] setFinishedSelectedImage:[UIImage imageNamed:@"MyTc-Select.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"MyTc.png"]];
[[AppDelegate.Tabctrl.tabBar.items objectAtIndex:2] setFinishedSelectedImage:[UIImage imageNamed:@"Browse-Select.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"Browse.png"]];
[[AppDelegate.Tabctrl.tabBar.items objectAtIndex:3] setFinishedSelectedImage:[UIImage imageNamed:@"Instore-Select.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"Instore.png"]];
[[AppDelegate.Tabctrl.tabBar.items objectAtIndex:4] setFinishedSelectedImage:[UIImage imageNamed:@"More-Select.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"More.png"]];
图片不适合标签栏
out put
有一些设计问题是我如何解决这个问题
图像遍历标签栏,其他一些背景图像显示在选定的标签中(查看第二个标签页)。
如何解决此问题
答案 0 :(得分:2)
降低TabBar中的图像可能会改变imageInsets:
尝试类似的事情:
UITabBarItem *tabBarItem1 = [AppDelegate.Tabctrl.tabBar.items objectAtIndex:0];
[tabBarItem1 setFinishedSelectedImage:[UIImage imageNamed:@"Home-Select.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"Home.png"]];
tabBarItem1.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);