简体   繁体   English

Xcode 6中的UITabbar

[英]UITabbar in Xcode 6

I have UITabbarController with 4 tabs in iPhone 4, 4s, 5, 5S it is woking fine with tabbar item image 我在iPhone UITabbarControllerUITabbarController有带有4个标签的UITabbarController与标签栏项图像一起正常工作

在此处输入图片说明

But in iPhone 6 and iPhone 6 plus is looking wired. 但是在iPhone 6和iPhone 6 plus中看起来像是有线的。 Is it need to put different images for both iPhone 6 and iPhone 6 plus ? iPhone 6和iPhone 6 plus是否需要放置不同的图像? How can I set this images. 如何设置此图像。

in iphone 6 在iPhone 6中

在此处输入图片说明

And, iPhone 6 Plus 而且, iPhone 6 Plus

在此处输入图片说明

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. 这里的问题不仅在于分辨率不同,还在于iPhone 6和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. 这意味着您必须为iPhone 6和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! 希望有帮助!

You need to make new size for iPhone 6 and iPhone 6 Plus. 您需要为iPhone 6和iPhone 6 Plus新建尺寸。

Indeed they have new resolution: iPhone 6 (1334-by-750-pixel) and the iPhone 6 Plus (1920-by-1080-pixel). 实际上,它们具有新的分辨率:iPhone 6(1334 x 750像素)和iPhone 6 Plus(1920 x 1080像素)。

Moreover if you are using auto-Layout you need to update your constraints. 此外,如果您使用自动版式,则需要更新约束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM