I have an app that is using a UITabBar and UINavigationBar. I am creating a UIImageView that contains my background image and then add that UIImageView to my self.view as a subview. This causes the background to appear “squished” vertically. The background image is not starting until the bottom of the NavBar and then runs down behind the TabBar.
Here’s the code I’m using to add the background:
UIImageView* backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
[backgroundView setFrame:CGRectMake(0, 0, 320, 480)];
[self.view addSubview:backgroundView];
Any ideas about how to keep the actual size of the background would be greatly appreciated.
First off, you won’t have 480 points of height to use with a
UINavigationBarpresent on anything less than an iPhone/iPod 5. You should useself.view.frame.size.heightto get the actual size. Really, you should just set the frame to the view’s bounds.Secondly, you should set the
contentModeproperty of theUIImageView.That should solve your problems.