Xcode 6 中的 UITabbar [英] UITabbar in Xcode 6
问题描述
我有 UITabbarController
在 iPhone 4, 4s, 5, 5S 中有 4 个标签,标签栏项目图像很好
I have UITabbarController
with 4 tabs in iPhone 4, 4s, 5, 5S it is woking fine with tabbar item image
但在 iPhone 6 和 iPhone 6 plus 中看起来是有线的.是否需要为 iPhone 6 和 iPhone 6 plus 放置不同的图像?如何设置此图像.
But in iPhone 6 and iPhone 6 plus is looking wired. Is it need to put different images for both iPhone 6 and iPhone 6 plus ? How can I set this images.
在 iphone 6 中
而且,iPhone 6 Plus
推荐答案
我遇到了同样的问题.这里的问题不仅在于分辨率不同,而且实际上 iphone 6 和 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. 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
这意味着您必须为 iphone 6 和 6 plus 使用不同的背景图片.我不确定这是否是最有效的方法,但它为我解决了这个问题:
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"];
}
希望有帮助!
这篇关于Xcode 6 中的 UITabbar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!