I'd like an image to take up all of a navigation bar. This is the navigation that comes with a navigation based app. It appears on the RootViewController with the accompanying UITableView. I've seen some examples of how this might work.
Set navigation bar title:
UIImage *image = [UIImage imageNamed:#"TableviewCellLightBlue.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[self.navigationController.navigationBar.topItem setTitleView:imageView];
The problem there is it only covers the title rather than the entire navigation bar.
There is also this thread: http://discussions.apple.com/message.jspa?messageID=9254241#9254241. Towards the end, the solution looks to use a tab bar, which I'm not using. It is that complicated to set a navigation bar background? Is there some other simpler technique?
I'd like to have a background for the navigation and still be able to use title text.
In your case, this solution found in another answer would work well.
With the "CustomImage" category added to UINavigationBar,
you can then just call:
UINavigationBar *navBar = self.navigationController.navigationBar;
UIImage *image = [UIImage imageNamed:#"yourNavBarBackground.png"];
[navBar setBackgroundImage:image];
This code should go in the method
- (void)viewWillAppear:(BOOL)animated
of the view controller where you want to have the custom image.
And, in that case you should better call:
[navBar clearBackgroundImage]; // Clear any previously added background image
before setBackgroundImage (otherwise it will be added multiple times...)
its changed for ios6, to make it work in ios 6 use:
UINavigationBar *navBar = self.navigationController.navigationBar;
UIImage *image = [UIImage imageNamed:#"image.png"];
[navBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
UIImage *image = [UIImage imageNamed:#"YourImage.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[self.navigationController.navigationBar addSubview:imageView];
There is actually a much easier way to add a background image to any UIView class or subclass. It requires no class categorization or extension (subclassing), and you can do this on an "as needed" basis. For example, to add a background image to a view controller's navigation bar, do the following:
self.navigationController.navigationBar.layer.contents = (id)[UIImage
imageNamed:#"background.png"].CGImage;
You'll need to remember to add the Quartz Core framework to your project and add #import <QuartzCore/QuartzCore.h> wherever you need to do this. This is a much cleaner, simpler way to alter the drawing layer of anything that inherits from UIView. Of course, if you want to accomplish a similar effect for all navigation bars or tab bars, then subclassing makes sense.
UIImage *logo = [UIImage imageNamed:#"my_logo"];
UIImageView *logoView = [[UIImageView alloc]initWithImage:logo];
logoView.frame = CGRectMake(0, 0, 320, 37);
UINavigationController *searchNavCtrl = [[UINavigationController alloc] initWithRootViewController:searchViewController];
searchNavCtrl.navigationBar.barStyle = UIBarStyleBlack;
//searchNavCtrl.navigationItem.titleView = logoView;
//[searchNavCtrl.navigationController.navigationBar.topItem setTitleView:logoView];
[searchNavCtrl.navigationBar addSubview:logoView];
[logoView release];
Just add this line .
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:#"NavBar.png"] forBarMetrics:UIBarMetricsDefault];
Bam! One line and done.
I used cmp's solution and added some logic to remove it as I only wanted a custom background image on home screen within on view appear.
HomeViewController.m
UIImage *image = [UIImage imageNamed:#"HomeTitleBG.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.tag = 10;
UIImageView *testImgView = (UIImageView *)[self.navigationController.navigationBar viewWithTag:10];
if ( testImgView != nil )
{
NSLog(#"%s yes there is a bg image so remove it then add it so it doesn't double it", __FUNCTION__);
[testImgView removeFromSuperview];
} else {
NSLog(#"%s no there isn't a bg image so add it ", __FUNCTION__);
}
[self.navigationController.navigationBar addSubview:imageView];
[imageView release];
I also tried to use the suggested clearBackgroundImage method but couldn't get it to work so I gave the image a tag and then removed it in the other viewcontrollers on view will appear.
OtherViewController.m
UIImageView *testImgView = (UIImageView *)[self.navigationController.navigationBar viewWithTag:10];
if ( testImgView != nil )
{
NSLog(#"%s yes there is a bg image so remove it", __FUNCTION__);
[testImgView removeFromSuperview];
}
`
just go the view controller and paste in super viewdidload
and replace your image in mainlogo and then set the navigation title in set your image logo
- (void)viewDidLoad
{
[super viewDidLoad];
//set your image frame
UIImageView *image=[[UIImageView alloc]initWithFrame:CGRectMake(0,0,70,45)] ;
//set your image logo replace to the main-logo
[image setImage:[UIImage imageNamed:#"main-logo"]];
[self.navigationController.navigationBar.topItem setTitleView:image];
}
Add code in appdelegate did finish with launching method
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
if([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0)
{
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"navigation_or.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:0.0 forBarMetrics:UIBarMetricsDefault];
}
else
{
[[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x067AB5)];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
// Uncomment to assign a custom backgroung image
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"navigation_or.png"] forBarMetrics:UIBarMetricsDefault];
// Uncomment to change the back indicator image
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
[[UINavigationBar appearance] setBackgroundColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:#""]];
// Uncomment to change the font style of the title
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
shadow.shadowOffset = CGSizeMake(0, 0);
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName,shadow, NSShadowAttributeName,[UIFont fontWithName:#"HelveticaNeue-Bold" size:17], NSFontAttributeName, nil]];
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:0.0 forBarMetrics:UIBarMetricsDefault];
}
Related
How can i specify the tint of images when a tab is selected and unselected?
I have tried this but it doesnt work:
[[UITabBar appearance] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];
This makes the selected image tint red(not green) and unselected tint gray (not red).
You can set the tint color for selected and unselected tab bar buttons like this:
[[UIView appearanceWhenContainedIn:[UITabBar class], nil] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];
The first line sets the unselected color - red in this example - by setting the UIView's tintColor when it's contained in a tab bar. Note that this only sets the unselected image's tint color - it doesn't change the color of the text below it.
The second line sets the tab bar's selected image tint color to green.
Are you using the template-version of your images?
Instead of setting your images with [UIImage imageNamed: #"MyImage"], set them with [[UIImage imageNamed: #"MyImage"] imageWithRenderingMode: UIImageRenderingModeAlwaysTemplate].
This setup along with your code should solve this issue.
You have to use the new Image rendering modes introduced in iOS 7 (UIImageRenderingModeAlwaysOriginal and UIImageRenderingModeAlwaysTemplate )see my answer to a similar question:
Hope this helps
if you do not have many viewcontrollers. Here is my way to do it.
In your delegate method just place your tabbar bg Image. And set the UIImageView
Create UITabbar intance in AppDelegate.h
#property (nonatomic,retain) UITabBar *tabbar;
And
#synthesize tabbar;
UITabBarController *tabBarController =
(UITabBarController *)self.window.rootViewController;
tabbar = [tabBarController tabBar];
[tabbar setBackgroundImage:[UIImage imageNamed:#"tabbarBg.png"]];
NSArray *tabImageArray = [NSArray arrayWithObjects:
[UIImage imageNamed:#"tab1Hover.png"],
[UIImage imageNamed:#"tab2.png"],
[UIImage imageNamed:#"tab3.png"],
[UIImage imageNamed:#"tab4.png"],
[UIImage imageNamed:#"tab5.png"],
nil];
for (int i = 0; i<5; i++) {
UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(20+i*60+i*3.5, 10, 25, 21)];
[image setContentMode:UIViewContentModeScaleAspectFit];
[image setImage:[tabImageArray objectAtIndex:i]];
[image setTag:10+i];
[tabbar addSubview:image];
}
Then every ViewController in tabbar add
-(void)viewWillAppear:(BOOL)animated
delegate method and in this method. You can change the Imageviews as shown below.
-(void)viewWillAppear:(BOOL)animated{
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
UITabBarController *tabBarController = (UITabBarController *)appDelegate.window.rootViewController;
NSArray *tabImageArray = [NSArray arrayWithObjects:
[UIImage imageNamed:#"tab1Hover.png"],
[UIImage imageNamed:#"tab2.png"],
[UIImage imageNamed:#"tab3.png"],
[UIImage imageNamed:#"tab4.png"],
[UIImage imageNamed:#"tab5.png"],
nil];
for (int i = 0; i<5; i++) {
UIImageView *image = (UIImageView*)[tabbar viewWithTag:10+i];
[image setImage:[tabImageArray objectAtIndex:i]];
}
}
So, just costumize tabImageArray in every View controller. Then you can use it.
I works on iOS 7 as well.
I have set a custom navigationbar in my appdelegate. You can see the code over here.
UIImage *image = [UIImage imageNamed:#"navbar.png"];
[[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
But now I'm working with the eventkit framework. What I want is when I go to eventdetails, that I get the standard navbar layout.So without the image.
EKEventViewController *vc = [[EKEventViewController alloc] init];
[vc.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
vc.event = [dataSource eventAtIndexPath:indexPath];
vc.allowsEditing = YES;
[calendar.navigationController pushViewController:vc animated:YES];
I've tried the following but it is not working.
Any help?
you can do one thing, take the screenshot of one viewController with default navigation bar , just crop only navigation bar area i.e. make image of 320 x 44 size.
when you want again your by default navigation bar , that time use this cropped image as background of navigation bar ,add following code
UIImage *image = [UIImage imageNamed:#"defaultNavbar.png"];
[[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
again when you navigate to another viewController having custom Navimage then again draw nav image by help of your custom image code i.e.
UIImage *image = [UIImage imageNamed:#"navbar.png"];
[[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
I am working on iPhone app. I have added Navigation bar Background image
With interface: -
#interface UINavigationBar (backgroundImageWithTitle)
And method: -
- (void)drawRect:(CGRect)rect
By this method Navigation bar background images is being set one time.
I want to call it from different .m files for assigning different images on bar.
How it can be implemented?
Thanks in advance.
CustomNavigation.h
#import <Foundation/Foundation.h>
#interface UINavigationBar (UINavigationBarCustomDraw){
}
#end
CustomNavigation.m
#implementation UINavigationBar (UINavigationBarCustomDraw)
- (void) drawRect:(CGRect)rect {
[self setTintColor:[UIColor colorWithRed:0.5f
green: 0.5f
blue:0
alpha:1]];
if ([self.topItem.title length] > 0) {
if ([self.topItem.title isEqualToString:#"First"]) {
[[UIImage imageNamed:#"First.png"] drawInRect:rect];
}
else if ([self.topItem.title isEqualToString:#"Second"]) {
[[UIImage imageNamed:#"Second.png"] drawInRect:rect];
}
CGRect frame = CGRectMake(0, 0, 320, 44);
UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
[label setBackgroundColor:[UIColor clearColor]];
label.font = [UIFont boldSystemFontOfSize: 20.0];
label.shadowColor = [UIColor colorWithWhite:0.0 alpha:1];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor whiteColor];
label.text = self.topItem.title;
self.topItem.titleView = label;
}
else {
[[UIImage imageNamed:#"wood.png"] drawInRect:rect];
self.topItem.titleView = [[[UIView alloc] init] autorelease];
}
}
#end
if u want to First.png to set navigationBar background image in FirstViewController then
in ur FirstViewController.m
-(void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.title=#"First";
[self.navigationController.navigationBar drawRect:CGRectMake(0, 0, 320, 480)];
}
if u want to Second.png to set navigationBar background image in SecondViewController then
in ur SecondViewController.m
-(void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.title=#"Second";
[self.navigationController.navigationBar drawRect:CGRectMake(0, 0, 320, 480)];
}
On iOS 5 this will not work but the good news is that there is a simple way of doing this
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"name"] forBarMetrics:UIBarMetricsDefault];
NOTE: This will only work on iOS 5 and above so make sure you check iOS version if you want to be backwards compatible.
Or other option so that code runs only incase of iOS 5
if([[UINavigationBar class] respondsToSelector:#selector(appearance)]) //iOS >=5.0
{
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"navigationBar.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"navBar-Landscape.png"] forBarMetrics:UIBarMetricsLandscapePhone];
}
I have tried this
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"name"] forBarMetrics:UIBarMetricsDefault];
It works fine for iOS 5.0 but got crashed in iOS 4.3 or below.
You have either set conditional i.e for
iOS 5
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"name"] forBarMetrics:UIBarMetricsDefault];
else
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"name"]];
but still there is issue that it shows line under image.
Or you can do in this way
self.navigationItem.hidesBackButton = YES;
UINavigationBar *navBar = self.navigationController.navigationBar;
UIImage *image = [UIImage imageNamed:#"image.png"];
UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 45)];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 45)];
imgView.image = image;
[tempView addSubview:imgView];
[navBar clearBackgroundImage];
[navBar addSubview:tempView];
[tempView release];
You can try in this way
if([[UINavigationBar class] respondsToSelector:#selector(appearance)]) //iOS >=5.0
{
//[[UINavigationBar appearance] setFrame:CGRectMake(0, 0, 320, 40)];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"navigationBar.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"navBar-Landscape.png"] forBarMetrics:UIBarMetricsLandscapePhone];
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];
}
and in else case you can add previous code i.e setBackgroundImage ....
Using (SDK 3.2.5.) - In one of my Apps I needed navigationBar with custom image both in landscape and portrait.
What I did was:
#implementation UINavigationBar (BackgroundImage)
- (void)drawRect:(CGRect)rect
{
UIImage *image;
if(self.frame.size.width == 320) //for iPhone - portrait will have 320 pix width.
{
image = [UIImage imageNamed: #"portraitNavigationBar.png"];
}
else
{
image = [UIImage imageNamed: #"landscapeNavigationBar.png"];
}
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
#end
Luckily my app supports rotation - so, when rotating - navigation bar automatically redraws itself.
But to manually redraw it - you can also call :
[navigationController.navigationBar setNeedsDisplay];
Hope you can help with this one too...
I wanted to customize my navigation bar by adding custom background picture. I found out perfect but a bit complicated method called:NavigationSwizzle. In previous project I worked without any serious problems, but now I'm stuck...
From my AppDelegate I am calling this static method:
#implementation SCAppUtils
+ (void)customizeNavigationController:(UINavigationController *)navController
{
//Customizing navigation BAR
UINavigationBar *navBar = [navController navigationBar];
[navBar setTintColor:kSCNavBarColor];
//Customizing TOOLBAR
[navController setToolbarHidden:NO animated:YES];
UIToolbar *toolBar = [navController toolbar];
UIImageView *imageView = (UIImageView *)[navBar viewWithTag:kSCNavBarImageTag];
UIImageView *imageView2 = (UIImageView *)[toolBar viewWithTag:kSCNavBarImageTag];
if (imageView == nil)
{
Utilities *utilities = [[Utilities alloc]init];
UIImage *img = [UIImage imageNamed:#"nav-bar-background.png"];
UIImage *img2 = [UIImage imageNamed:#"toolbar-background.png"];
imageView = [[UIImageView alloc] initWithImage:img];
imageView2 = [[UIImageView alloc] initWithImage:img2];
[imageView setTag:kSCNavBarImageTag];
[imageView2 setTag:kSCNavBarImageTag];
[navBar insertSubview:imageView atIndex:0];
[toolBar insertSubview:imageView2 atIndex:0];
[imageView release];
[imageView2 release];
[utilities release];
}
}
In rootNavigationController after calling second view controller by pushing it on the stack my right button, self.title, activityIndicator don't show. If I comment or set atIndex:-1 in line [navBar insertSubview:imageView atIndex:0]; then buttons show, but my customized background is gone and I get regular iPhone navigational tab.
In didSelectRowAtIndex of rootNavigationController I have:
//ADD BACK BUTTON TO VIEW
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:#"Home" style:UIBarButtonItemStyleDone target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
//Home Button color
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:166.0 / 255 green:179.0 / 255 blue:191.0 / 255 alpha:1.0];
//PUSH TO NEXT VIEW
[self.navigationController pushViewController:detailViewController animated:YES];
Thank you in advance...
If you need more code or explanation, please don't hesitate to ask me...
Best regards,
Luka
EDIT:
Ok, I can make this question much simpler. I have a custom background image in my navigation bar. This image is obviously covering my
self.navigationItem.title = #"TITLE";
If I put alpha to: 0.3 of imageView that is in the background I can see my title:
imageView = [[UIImageView alloc] initWithImage:image];
[imageView setAlpha:0.3];
[imageView setTag:kSCNavBarImageTag];
[navBar insertSubview:imageView atIndex:0];
So the question is how can I send my navigationItem.title to front? Is it a UIView class descendent?
EDIT 2:
Really weird thing is that title is visible (above background image) in the rootController but after pushing another viewController title goes behind te background imageView ?!
I honestly think you forgot to add this code in the main.m. You main.m should look something like this:
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "SCClassUtils.h"
int main(int argc, char *argv[])
{
[SCClassUtils swizzleSelector:#selector(insertSubview:atIndex:)
ofClass:[UINavigationBar class]
withSelector:#selector(scInsertSubview:atIndex:)];
[SCClassUtils swizzleSelector:#selector(sendSubviewToBack:)
ofClass:[UINavigationBar class]
withSelector:#selector(scSendSubviewToBack:)];
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
You might want to try this to customize your Navigationbar instead. I use it in my apps and it works like a charm
UIImage *theImage = [UIImage imageNamed:#"barImage.png"];
[self.navigationController.navigationBar insertSubview:[[[UIImageView alloc] initWithImage:theImage] autorelease] atIndex:0];
See if that fixes your issues with the buttons not appearing.
I found a solituion for my work. Create a view (viewBackground) with all the images and colors that conform the navigation bar and then y convert it in a image and use it like a background
UIGraphicsBeginImageContextWithOptions(viewBackground.bounds.size, viewBackground.opaque, 0.0);
[viewBackground.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[UINavigationBar appearance] setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
how to display an image in the navigation bar of an iPhone application? (say, right after the title)
Here's how to have the image centered in the NavBar.
UIImage *image = [UIImage imageNamed: #"NavBarImage.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
self.navigationItem.titleView = imageView;
[imageView release];
This code is actually contained with the Apple source for the NavBar and can be found at the iPhone Developer Center at Apple.
The source shows you various ways to manipulate both the StatusBar & NavBar.
I haven't tested this but as UINavigationBar is a view you can add subViews to it.
UIImage* myImage = [UIImage imageNamed:#"Myimage.png"];
UIImageView* myImageView = [[UIImageView alloc] initWithImage:myImage];
myImageView.frame.origin.x = 30.0; // You will have to find suitable values for the origin
myImageView.frame.origin.y = 5.0;
[myTabbar addSubView:myImageView];
[myImageView release];
You can use things like the backItem property to calculate the position of your image view.
If you want the image at the right of the nav bar, you can define it as a custom button with no action when presed, like this
UIButton* fakeButton = (UIButton *) [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"yourimage.png"]];
UIBarButtonItem *fakeButtonItem = [[UIBarButtonItem alloc] initWithCustomView:fakeButton];
self.navigationItem.rightBarButtonItem = fakeButtonItem;
[fakeButtonItem release];
[fakeButton release];
Simply Place that code in - (void)viewWillAppear:(BOOL)animated; so it'll work fine
and add one image having size 320x40 named Top Bar
UIImage *image = [UIImage imageNamed: #"TopBar.png"];
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
the navigation bar has a property called title view - set this to the image you like. Since the titleView overwrites the title of the nav bar you have to include the desired title in the image file. Still set the title to what you want so it appears on the back button when you push a view Controller
I encountered the same problem.Found out the best solution
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:#"background_image.png"] forBarMetrics:UIBarMetricsDefault];
Hope this would help....
Just write your own navigation bar. Therefore you have to disable the Navigation Bar fist:
Disable the top bar in the interface builder by selecting your Navigation Controller in
your Storyboard: Attributes Inspector -> Simulated Metrics -> Top Bar: select None
Afterwards you can add any HeaderView you like...
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, sFrame.size.width, 100)];
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:#"header_image.png"]];
self.headerView.backgroundColor = background;
// ...add buttons and labels
[self.view addSubview:headerView];