我目前正在使用Xcode 6更新一些旧的Xcode应用程序。
我有一个自定义标签栏,用于加载和看起来很好,但在Xcode 6中,它在标签栏的顶部产生了1px间隙,我无法摆脱,它看起来非常糟糕!
我已经阅读了其他一些类似的SO帖子,并遵循了所有建议,但似乎没有任何效果,1px差距仍然存在。
这是我的自定义标签条形码:
CGRect screenBound = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenBound.size;
CGRect tabbarTopFrame = CGRectMake(0,(screenSize.height - 59),320,10);
UIImageView *tabbarTop = [[UIImageView alloc] initWithFrame:tabbarTopFrame];
tabbarTop.image = [UIImage imageNamed:@"tabbar_top.png"];
[self.tabBarController.view addSubview:tabbarTop];
UIImage *selectedImage0 = [UIImage imageNamed:@"tabbar_introduction_active.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"tabbar_introduction_default.png"];
UIImage *selectedImage1 = [UIImage imageNamed:@"tabbar_nests_active.png"];
UIImage *unselectedImage1 = [UIImage imageNamed:@"tabbar_nests_default.png"];
UIImage *selectedImage2 = [UIImage imageNamed:@"tabbar_home_active.png"];
UIImage *unselectedImage2 = [UIImage imageNamed:@"tabbar_home_default.png"];
UIImage *selectedImage3 = [UIImage imageNamed:@"tabbar_dogowners_active.png"];
UIImage *unselectedImage3 = [UIImage imageNamed:@"tabbar_dogowners_default.png"];
UIImage *selectedImage4 = [UIImage imageNamed:@"tabbar_spotted_active.png"];
UIImage *unselectedImage4 = [UIImage imageNamed:@"tabbar_spotted_default.png"];
UITabBar *tabBar = self.tabBarController.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
UITabBarItem *item2 = [tabBar.items objectAtIndex:2];
UITabBarItem *item3 = [tabBar.items objectAtIndex:3];
UITabBarItem *item4 = [tabBar.items objectAtIndex:4];
[self.tabBarController.tabBar setClipsToBounds:YES];
[[UITabBar appearance] setBackgroundImage:[[UIImage alloc] init]];
item0.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
item1.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
item2.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
item3.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
item4.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
[item0 setImage:[unselectedImage0 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item1 setImage:[unselectedImage1 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item2 setImage:[unselectedImage2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item3 setImage:[unselectedImage3 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item4 setImage:[unselectedImage4 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item0 setSelectedImage:[selectedImage0 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item1 setSelectedImage:[selectedImage1 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item2 setSelectedImage:[selectedImage2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item3 setSelectedImage:[selectedImage3 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item4 setSelectedImage:[selectedImage4 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
这些图片都是在以前的应用程序代码中使用的,这是用Xcode 4编写的,然后一切正常,所以它必须是在Xcode 5或6或iOS7 / iOS8中已经改变的东西?
答案 0 :(得分:0)
虽然不是同一个问题,但这个SO帖子(update tab bar height in iOS 7/8 from iOS 6 - UITabBar)中的某些内容对我有帮助。
原来我根本没有对我的任何代码进行任何更改 - 但只是将图形的高度从49px更改为50px就解决了这个问题。
奇