为什么iPhone在启动时启动图像与主屏幕背景图像不匹配?
背景:为什么iPhone在启动时启动图像与主屏幕背景图像不匹配?
我有,我想推出图像完全相同作为主屏幕的背景图像的iPhone应用程序 - 这样在加载“启动图像”所示,然后当应用程序加载主屏幕的背景图像将是相同的,并完美地排队所以在背景在主画面viewDidLoad中感知
我相同的图像加载到一个UIImageView,占用了整个无变化窗口
问题:
- 我所得到的是有一个垂直偏移,所以在转换过程中一个显着的变化
- 它出现的问题主要是在为推出图像的垂直对齐,在它看起来发射图像的顶部开始高于该“运营商时间 - 电池”栏的底部 - 看起来这个发射图像可能定位于顶部,从这个顶部到顶部,而顶部主屏幕的背景图像(一旦加载完成)就是从“载体 - 时间 - 电池”栏的底部开始的
问题:为什么会有偏移?如何最好地解决这个问题?
感谢
有没有必要使用两个不同的图像为您的启动图像&背景图像。
只要设置你的背景图像的contentMode
到UIViewContentModeBottom
将解决这个问题。
例如:
backgroundImageView.contentMode = UIViewContentModeBottom;
的为Default.png必须为320x480像素(640×960 @ 2X)视图后的启动仅仅是320x460(640x920 @ 2X),因为状态栏的。
尝试为您的应用使用2个不同的Backgroundimages 320x480用于启动(顶部20px可以为空)和320x460(640x920 @ 2X)。
该解决方案适用于标准和视网膜iPhone和iPad在纵向或横向带或不带标签栏。这是必要的,因为iPhone启动图像与状态栏重叠,但是iPad没有。来源:采用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;
}
图像是:
- 默认〜iphone.png
- [email protected]~iphone.png
- 默认画像〜ipad.png
- 默认 - [email protected]~ipad.png
- Default-Landscape〜iphone。PNG
- 默认 - 风景〜ipad.png
- [email protected]~iphone.png
- [email protected]~ipad.png
在Interface Builder把你的背景图像像这样的:
而且,这条被称为*“状态栏” * – EmptyStack