Search code examples
iosiphone-4

Background Image starts repeating when Screen height is changed


My background image is 320*436. It's working perfectly on iPhone4 but when I run on iPhone5 the background starts repeating.

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

How do I make this compatible with iPhone5?


Solution

  • Write at beginning if ViewDidLoad if not using xib. if using xib drag and drop a full screen imageview at 0 index of UIView. Set image to it. Set autoresizemask to UIViewAutoresizingFlexibleWidth

    UIImageView* imageView=[[UIImageView alloc] initWithFrame:self.view.frame];
    imageView.image=[UIImage imageNamed:@"bg.png"];
    [self.view addSubview:imageView];
    [imageView release];