Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Setting Background Images for Various Screen Sizes

I am up to this video and i have tried all of the things recommended by ben after his app did not work either. i have found that app at the size of 3.5 inches works but at 4 inches i just have a white background. here is the code i had to display the bigger picture '''objective-c

  • (void)viewDidLoad { [super viewDidLoad];

    if ([UIScreen mainScreen].bounds.size.height == 568) { self.backgroundImageView.image = [UIImage imageNamed:@"loginBackground-568h"]; }

} '''

I having that same problem, did you figure it out?

Judah Morales
Judah Morales
2,481 Points

Did anyone ever come up with an answer for this? I'm currently running into the same issue and it's very frustrating.

1 Answer

Something i came across might help

CGRect screenBounds = [[UIScreen mainScreen] bounds];
if 
(screenBounds.size.height == 568) {
    // code for 4-inch screen
} else
 {
(screenBounds.size.height == 480)
    // code for 3.5-inch screen
}

I having that same problem, but this code didn't work for me