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 Build a Simple iPhone App (iOS7) Designing your App Programming a Background Image

Gaetano Isidori
Gaetano Isidori
3,451 Points

How to fit the screen with an image when programming your backround?

Im currently running the crystal ball app on iphone 6 in xcode. The background image is not filling the screen properly and this is my code: UIImage *backgroundImage = [UIImage imageNamed:@"background"]; UIImageView *ImageView = [[UIImageView alloc] initWithImage:backgroundImage]; [self.view insertSubview:ImageView atIndex:0];

How do i get the image to properly display? thanks.

1 Answer

Kevin Hamil
Kevin Hamil
8,203 Points

At a quick glance you're code for populating the background image looks correct. If you're seeing the image then that part is fine. The positioning of your background image is handled by constraints.

Constraints is covered in the last video of Stage 5. http://teamtreehouse.com/library/build-a-simple-iphone-app-ios7-2/designing-your-app/using-auto-layout-2