关于一点短的背景图像

时间:2013-07-24 03:04:48

标签: ios objective-c

请原谅我这个问题是否有另一个答案,但我找不到找到问题的好方法。

在iPhone5模拟器上,尽管尺寸合适,但我的背景图像还是有点短。见截图:

enter image description here

我的图片都是640px×1136px .p​​ng文件,我的图片代码如下:

backgroundImage1 = [[UIImageView alloc] initWithFrame:frame];
        [backgroundImage1 setContentMode:UIViewContentModeScaleAspectFill];
        [backgroundImage1 setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];
        [self addSubview:backgroundImage1];

我会在手机上试试,但我的证书已过期,所以我不能直到开发中心重新上线。

有什么想法吗?

2 个答案:

答案 0 :(得分:3)

更改

[backgroundImage1 setContentMode:UIViewContentModeScaleAspectFill];

 [backgroundImage1 setContentMode:UIViewContentModeScaleToFill];

以便它填满整个屏幕

希望这有帮助!

答案 1 :(得分:1)

这就是我最终做的事情:

frame.origin.y -= 10.0f;
frame.size.height += 20.0f;

这填满了屏幕和状态栏。我不得不在页面上调整其他东西的位置,但它有效。其他更好的答案非常受欢迎!或者只是对正在发生的事情的解释。