Arslan Asim
Arslan Asim

Reputation: 1302

UITabbar background image IPhone 6 issue

I'm developing Tab bar Application and found strange issue on iPhone 6 enter image description here

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

enter image description here

Upvotes: 1

Views: 178

Answers (1)

Arslan Asim
Arslan Asim

Reputation: 1302

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:@"[email protected]"];
}
[tabBar setBackgroundImage:tabBarBackground];

Upvotes: 1

Related Questions