简体   繁体   中英

UITabbar background image IPhone 6 issue

I'm developing Tab bar Application and found strange issue on 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

在此处输入图片说明

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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