开发者

Background image not stretching when rotating

开发者 https://www.devze.com 2023-03-19 10:43 出处:网络
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

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

精彩评论

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