I want to set the background image of a view. I use three images: backgroundimage.png (size 320 x 480), backgroundimage@2x.png (size 640 x 960) and backgroundimage-568h@2x.png (size 640 x 1136)
that works for iphone 3g size. But when I test it for retina size the background image is just a small part of the original image. I think, that I have to downscale the image somehow, or set a frame for it, but I just don't know how.
Thanks for any help ;)
thats the code:
self.view.backgroundColor = [UIColor clearColor];
UIImage *backgroundImage = [[UIImage alloc]init];
if ([[UIScreen mainScreen] bounds].size.height == 568) {
backgroundImage = [UIImage imageNamed:@"background-568h@2x"];
}
else{
backgroundImage = [UIImage imageNamed:@"background"];
}
self.view.backgroundColor = [UIColor colorWithPatternImage:backgroundImage];
My first guess is because of the misuse of
colorWithPatternImage
. This should only be used if you have a pattern image that you wish to have tiled. Instead try creating a UIImageView the size of the view, and then adding it as a subview of self.view.