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 setBackgr开发者_运维百科oundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"mainbg.png"]]];
You can programmatically set the autoresizingMask
to UIViewAutoresizingFlexibleWidth
and UIViewAutoresizingFlexibleHeight
, e.g.
[imageView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
精彩评论