Greg
Greg

Reputation: 34798

why is iPhone launch image not lining up with main screen background image at transistion?

Background:

Issue:

QUESTION: Why is there an offset? How best to fix this?

thanks

Upvotes: 3

Views: 2540

Answers (3)

William Entriken
William Entriken

Reputation: 39273

This solution works for standard and retina on iPhone and iPad in Portrait or Landscape with or without the Tab Bar. This is necessary because the iPhone Launch Image overlaps the status bar, but the iPad one does not. Source: http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                                         duration:(NSTimeInterval)duration
{
    if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
            [self.backgroundImage setImage:[UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"Default" ofType:@"png"]]];
        else
            [self.backgroundImage setImage:[UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"Default-Portrait" ofType:@"png"]]];
    } else {
        [self.backgroundImage setImage:[UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"Default-Landscape" ofType:@"png"]]];
    }
 
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
        self.backgroundImage.transform = CGAffineTransformMakeTranslation(0, -20);
    else 
        self.backgroundImage.transform = CGAffineTransformIdentity;
}

Images used are:

  • Default~iphone.png
  • Default@2x~iphone.png
  • Default-Portrait~ipad.png
  • Default-Portrait@2x~ipad.png
  • Default-Landscape~iphone.png
  • Default-Landscape~ipad.png
  • Default-Landscape@2x~iphone.png
  • Default-Landscape@2x~ipad.png

In Interface Builder put your background image in like this:

enter image description here

Upvotes: 0

xuzhe
xuzhe

Reputation: 5120

There is no need to use two different images for your start up image & background image.

Just set your background imageView's contentMode to UIViewContentModeBottom will fix this problem.

for example:

backgroundImageView.contentMode = UIViewContentModeBottom;

Upvotes: 3

nettz
nettz

Reputation: 173

The Default.png has to be 320x480(640x960@2x) your view after the startup is only 320x460(640x920@2x) because of the Statusbar.

Try to use 2 different Backgroundimages 320x480 for the startup(top 20px can be blank) and 320x460(640x920@2x) for your app.

Upvotes: 1

Related Questions