Reputation: 34798
Background:
I have an iPhone application for which I want the launch image to be exactly the same as the background image for the main screen - so that upon loading the "launch image" is shown, then when the apps loads the main screen the background image will be the same, and perfectly line up so there is no change in background perceived
in the main screen viewDidLoad I load the same image into a UIImageView that takes up the entire window
Issue:
QUESTION: Why is there an offset? How best to fix this?
thanks
Upvotes: 3
Views: 2540
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:
In Interface Builder put your background image in like this:
Upvotes: 0
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
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