我制作了一个自定义标签栏,其中一个延伸到栏外。有一条线与中心标签栏重叠。无论如何我可以摆脱这个或隐藏它吗?
为此,我只设置标签栏图像:
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UITabBar *tabBar = tabBarController.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];
tabBarItem1.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
tabBarItem3.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
[tabBarItem1 setFinishedSelectedImage:[UIImage imageNamed:@"scheduleTabBarImageSel.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"scheduleTabBarImage.png"]];
[tabBarItem3 setFinishedSelectedImage:[UIImage imageNamed:@"favoritesTabBarImageSel.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"favoritesTabBarImage.png"]];
[tabBarItem2 setFinishedSelectedImage:[UIImage imageNamed:@"searchTabBarImageSel.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"searchTabBarImage.png"]];
知道怎么隐藏这条线吗?感谢
答案 0 :(得分:6)
如果我正确理解你的问题,问题在于标签栏顶部的1-2英寸像素阴影。如果是这种情况,您可以像导航栏一样删除阴影。只需启用剪辑即可。
[self.tabBarController.tabBar setClipsToBounds:YES];
答案 1 :(得分:0)
这似乎对我有用:
[[UITabBar appearance] setBackgroundImage:[[UIImage alloc] init]];