Background image not fit to the screen

776 Views Asked by At

Here in my app i used the background image size as 320 x 480,but in the end of the screen some portions not visible,here my code

self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"ibg.png"]];

Please help me to solve to make the image screen fit.. enter image description here

2

There are 2 best solutions below

0
On BEST ANSWER

If the invisible portion has height equal to 50 pixel, then could you please try resize your image (ibg.png) to 320 x 430 using

- (UIImage *)imageWithImage:(UIImage *)image convertToSize:(CGSize)size {
    UIGraphicsBeginImageContext(size);
    [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
    UIImage *destImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return destImage;
}

after that

self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"ibg.png"]];

should make it, hope it help, please give me a feedback, thanks.

0
On

Your image may be offset by the status bar, which takes up 20 pixels (or 'points') of space at the top of the screen. If your status bar is visible, the Y position of your full-screen background image must be -20 rather than 0.