简体   繁体   English

UITabbar背景图片iPhone 6问题

[英]UITabbar background image IPhone 6 issue

I'm developing Tab bar Application and found strange issue on iPhone 6 我正在开发Tab栏应用程序,并在iPhone 6上发现了奇怪的问题 在此处输入图片说明

Notice that image is not wide enough for full screen but repeated. 请注意,图像的宽度不足以全屏显示,但会重复显示。 I have set image through both storyboard and programmatically I have also have 2x and 3x images placed in Images.xcassets 我已经通过情节提要和编程方式设置了图像,并且在Images.xcassets中也放置了2x和3x图像。

在此处输入图片说明

For any one who comes here later, here is what i do 对于以后再来的任何人,这就是我要做的

After Some tries i've used a hack as follow 经过一番尝试之后,我使用了如下技巧

  • Do not used images from assets instead place them as files (we do before assets) 不要使用资产中的图片,而是将它们作为文件放置(我们先处理资产)
  • Check if we have iPhone 6 and user @3x image, (i was not sure why it was not picked by assets but it do in this manner) 检查我们是否有iPhone 6和用户@ 3x图像,(我不确定为什么资产没有选择它,但是它是以这种方式进行的)

Following is code 以下是代码

#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];

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

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