[英]ios7 - Custom UItabbar has a gap in the bottom
我试图使用图像为选定和未选择状态创建自定义UITabbar。
这是我的代码:
if ([UIImage instancesRespondToSelector:@selector(imageWithRenderingMode:)]) {
tab_01_on_image = [[UIImage imageNamed:@"Tabbar_on_01"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
tab_01_off_image = [[UIImage imageNamed:@"Tabbar_off_01"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
} else {
tab_01_on_image = [UIImage imageNamed:@"Tabbar_on_01"] ;
tab_01_off_image = [UIImage imageNamed:N@"Tabbar_off_01"] ;
}
[[[self.tabBarController.tabBar items] objectAtIndex:index] setFinishedSelectedImage:tab_01_on_image withFinishedUnselectedImage:tab_01_off_image];
此图显示问题,红色是差距:
编辑添加代码以创建UITabbar
self.tabBarController = [[BaseTabbarController alloc] init];
self.tabBarController.delegate = self;
self.tabBarController.viewControllers = @[navControll1, navControll2, navControll3, navControll4, navControll5];
self.window.rootViewController = self.tabBarController;
我感谢你们提供的任何帮助
我终于找到了解决方案。 更改每个tabbarItem的imageInsets就可以了。
tabBarItem1.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
tabBarItem2.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
tabBarItem3.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
tabBarItem4.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
tabBarItem5.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.