简体   繁体   中英

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.

在主窗口笔尖上添加一个ImageView,并将所有视图的bg颜色设置为clearColor。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM