简体   繁体   中英

UIView Background Image Not Scaling on Device Rotation

I'm giving a view a background image with [[self myView] setBackgroundColor: [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.png"]]]; .

It looks fine until rotating the device. It doesn't seem to scale and stays its original size.

If I change to a different view and back again via the Tab Bar, it will now be scaled properly.

Does anyone have any ideas?

Thank you

The person who wrote suggesting resetting the frame, thanks your idea helped. I don't know why you erased your answer.

I added a line of code in each rotation block, something like this: [[self view] setFrame:CGRectMake(0,0,x,y);

The background image now scales properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM