开发者

Background image not stretching when rotating

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)];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜