2

UITabbarController在 iPhone 4、4s、5、5S 中有 4 个标签,它与标签栏项目图像一起工作正常

在此处输入图像描述

但在 iPhone 6 和 iPhone 6 plus 中看起来是有线的。是否需要为 iPhone 6 和 iPhone 6 plus 放置不同的图像?我该如何设置这些图像。

在 iPhone 6

在此处输入图像描述

而且,iPhone 6 Plus

在此处输入图像描述

4

2 回答 2

4

I ran into this same issue. The problem here is not only the different resolution, but the fact that the size of the bounds is actually wider for iphone 6 and iphone 6 plus. By running the simulator on all different phone types I found the following:

Tab bar Bounds
iPhone 6 plus:  414 x 49
iPhone 6:       375 x 49
iPhone 5:       320 x 49
iPhone 4        320 x 49

This means that you must use different background images for iphone 6 and 6 plus. I'm not sure if this is the most efficient way to do this, but it fixed it for me:

UITabBarController *tabBarController = (UITabBarController *) self.parentViewController;
UITabBar *tabBar = tabBarController.tabBar;

if ([[UIScreen mainScreen] bounds].size.height > 700) {
    tabBar.selectionIndicatorImage = [UIImage imageNamed:@"tabbar-selected6Plus"];
} else if ([[UIScreen mainScreen] bounds].size.height > 600) {
    tabBar.selectionIndicatorImage = [UIImage imageNamed:@"tabbar-selected6"];
} else {
    tabBar.selectionIndicatorImage = [UIImage imageNamed:@"tabbar-selected"];
}

Hope that helps!

于 2015-01-14T17:33:29.310 回答
0

您需要为 iPhone 6 和 iPhone 6 Plus 制作新尺寸。

事实上,它们有了新的分辨率:iPhone 6(1334 x 750 像素)和 iPhone 6 Plus(1920 x 1080 像素)。

此外,如果您使用自动布局,则需要更新约束。

于 2014-11-04T09:01:04.870 回答