Is there a way to have a background image remain constant across all views in a navigation controller? Currently I am loading the same background in each view's viewDidLoad
method but this shows the background image move when navigating from view to view. I'd rather just the content of the view infront of the background "slide" on/off screen, but the background stay stationary. This is my current background image loading code:
UIImageView *background = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
background.image = [UIImage imageNamed:@"InfoBackground.png"];
[self.view addSubview:background];
[self.view sendSubviewToBack:background];
[background release];
Thanks!
i think the better idea is place background image on window and set all view's(all viewcontroller's view) background color to clear color [UIColor clearColor].
Hm, perhaps if you look at the documentation (scroll down to Figure 2) you will get an idea of what you're dealing with. Because you are setting the background image for each of your view controllers that are being pushed into the UINavigationController, you will get that animation. What you need to do is set the background image into the nav controller itself.
I believe
myNavController.view insertSubview:myImageView atIndex:0
should work. If your image needs to fill in behind the content view exactly, you could set the frame coordinates based on the coordinates and/or heights of the navbar and toolbar, which can be accessed through the navigation controller's properties. If not, just set the frame to the superview's bounds.Let me know how it goes.
Edit: Oh, note that you would need to make sure each of your view controllers had transparent backgrounds.
if you want background image static then there is only one way but i don't know that is possible or not, If we put image in window and make navigation controller transparent then it's stay static whatever you will do. because we are not changing window while push or pop.
I am just suggesting try this way i haven't tried like this.