【问题标题】:UITabbar background image IPhone 6 issueUITabbar 背景图片 iPhone 6 问题
【发布时间】:2015-10-01 14:40:08
【问题描述】:
我正在开发标签栏应用程序并在 iPhone 6 上发现了奇怪的问题
请注意,图像不够宽,无法全屏显示,而是重复出现。
我已经通过情节提要和编程设置了图像
我还在 Images.xcassets 中放置了 2x 和 3x 图像
【问题讨论】:
标签:
ios
uitabbarcontroller
uitabbar
iphone-6
【解决方案1】:
对于以后来这里的任何人,这就是我的工作
经过一些尝试后,我使用了以下技巧
- 不要使用资产中的图像,而是将它们作为文件放置(我们在资产之前这样做)
- 检查我们是否有 iPhone 6 和用户 @3x 图像,(我不知道为什么它没有被资产选择,但它以这种方式选择)
以下是代码
#define isIPhone6 [[UIScreen mainScreen] bounds].size.height > 568 ? YES : NO
UITabBar *tabBar = tabBarController.tabBar;
UIImage* tabBarBackground = [UIImage imageNamed:@"tab_bar1.png"];
if (isIPhone6) {
tabBarBackground = [UIImage imageNamed:@"tab_bar2@3x.png"];
}
[tabBar setBackgroundImage:tabBarBackground];