Hi All,
I have a background image which is created in viewDidLoad
All fine. Then, rotation:
However, this transform has no effect. View rotates, but the image stays in vertical position, so the right half of the view has no bg.
I've also tried to set new rect on the bgView as you can see form the commented code. Doesn't help, makes things worse. In landscape things are the same as w/o rect change, but when the view goes back to portrait bg image is moved down by 40-50 pix. No idea why.
I've also tried to bring bgView to front, rotate and send back again, no effect either. I'm sortta out of ideas here
So, what am I missing?
I have a background image which is created in viewDidLoad
Code:
bgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background_2.png"]];
[self.view addSubview:bgView];
[self.view sendSubviewToBack:bgView];
All fine. Then, rotation:
Code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return TRUE;
}
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
//[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
return;
CGRect bgRect = bgView.bounds;
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight ||
toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
//[bgView setBounds:CGRectMake(bgRect.origin.y, bgRect.origin.x, bgRect.size.height, bgRect.size.width)];
bgView.transform = CGAffineTransformMakeRotation(3.14159265/2);
}
if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
{
//[bgView setBounds:CGRectMake(bgRect.origin.y, bgRect.origin.x, bgRect.size.height, bgRect.size.width)];
bgView.transform = CGAffineTransformMakeRotation(3.14159265/2);
}
}
However, this transform has no effect. View rotates, but the image stays in vertical position, so the right half of the view has no bg.
I've also tried to set new rect on the bgView as you can see form the commented code. Doesn't help, makes things worse. In landscape things are the same as w/o rect change, but when the view goes back to portrait bg image is moved down by 40-50 pix. No idea why.
I've also tried to bring bgView to front, rotate and send back again, no effect either. I'm sortta out of ideas here
So, what am I missing?