0
我想設置一個視圖的背景圖像。我使用三個圖像:backgroundimage.png(尺寸320 x 480),[email protected](尺寸640 x 960)和[email protected](尺寸640 x 1136)爲Iphone 3g,Iphone 4s和Iphone 5設置背景圖像
適用於iphone 3g尺寸。但是當我測試視網膜大小時,背景圖像只是原始圖像的一小部分。我認爲,我必須以某種方式縮小圖像的尺寸,或爲其設置框架,但我不知道如何。
感謝所有幫助;)
多數民衆贊成代碼:
self.view.backgroundColor = [UIColor clearColor];
UIImage *backgroundImage = [[UIImage alloc]init];
if ([[UIScreen mainScreen] bounds].size.height == 568) {
backgroundImage = [UIImage imageNamed:@"[email protected]"];
}
else{
backgroundImage = [UIImage imageNamed:@"background"];
}
self.view.backgroundColor = [UIColor colorWithPatternImage:backgroundImage];
非常感謝。有用。 –
@PeterK如果答案有幫助,請點擊帖子旁邊的「複選標記」,將其標記爲正確。 –