I would like the background image of a view to change every time there's rotation. The image changes, yet when the rotation is horizontal, it cuts it off as if it were a portrait image. Here's what I mean:
This orientation is horizontal, yet the image is cropped for portrait dimensions. The actual image is fit to be horizontal.
Here's my code:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
// called after rotation occurs
if (fromInterfaceOrientation == UIInterfaceOrientationPortrait) {
// now horizontal
imageToLoad = [UIImage imageNamed:@"H0.png"];
} else {
// now portrait
imageToLoad = [UIImage imageNamed:@"P0.png"];
}
UIGraphicsBeginImageContext(self.view.frame.size);
[imageToLoad drawInRect:self.view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.view.backgroundColor = [UIColor colorWithPatternImage:image];
}
How could I solve this? Thank you.