I am using the following code to set a background in my iphone app.

[[self view] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"background_final.png"]]];

The problem is that if I try the app in iPhone 5.. retina 4" the background image gets tiled instead of having black spaces where there should not be any images.

I have a Default-568h@2x.png in the app, and it has the correct dimensions but still I am not getting the right image background.

Any Ideas on how to fix this?

有帮助吗?

解决方案

delete the Default-568h@2x.png and you will get the expected results

其他提示

1) Default-568h@2x.png is only for the launch image. It is not used anywhere in the app.

2) colorWithPatternImage will repeat if the image size is lesser than the view

So, you can use the image with the height that will fit to the 4" screen. This will work for 3.5" screen also.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top