Centurion
Centurion

Reputation: 14314

How to set header image for all screens (UIViewControllers) in xcode interface builder?

Currently, I'm implementing a simple Tabbed application and I need to show some header logo image on all screens. Obviously, the most simple way is to put an image in all xib files. Just curious are there any other options?

UPDATE: If I place an image inside window object in MainWindow.xib then it appears on all view controllers but it will not rotate. If I place an image outside the window then it will not display at all.

Upvotes: 0

Views: 1080

Answers (2)

h_kassem
h_kassem

Reputation: 450

Make all your views (xib) have a clearColor background and a margin on top (for the header), then place your header image in your AppDelegate Object as a subview of the tabBarController:

UIImageView *nav=[[UIImageView alloc] initWithFrame:CGRectMake(0, self.window.frame.size.height/24, self.window.frame.size.width, 44)];
[nav setImage:[UIImage imageNamed:@"header.png"]];
[self.tabBarController.view addSubview:nav];
[nav release];

I think this will solve the rotation problem.

Upvotes: 1

Manali
Manali

Reputation: 573

Add an ImageView on the main window nib and set bg color of all your views as clearColor.

Upvotes: 2

Related Questions