I have set the background for a given view using the following code, however, when I rotate the device, it just repeats the image. what I want is for it to stretch to the rotated width and height.. I know how to do it in Interface Builder but this view does not have a nib.
[myView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"mainbg.png"]]];
You can programmatically set the
autoresizingMasktoUIViewAutoresizingFlexibleWidthandUIViewAutoresizingFlexibleHeight, e.g.