Background image for UINavigationBar

Send Snippet To: Save this snippet to Code Collector Pro -- view all powidl's snippets
language: Objective-C
license: Other

Code for Snippet:

/************************ Navigation Bar: Customized View *******************************/
     self.navigationController.navigationBar.frame = CGRectMake(0,0,320,60);
     UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] init];
     temporaryBarButtonItem.title = @"MENU";
     self.navigationItem.backBarButtonItem = temporaryBarButtonItem;
     [temporaryBarButtonItem release];
     UIView *titlev = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,44)];
     UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image1.png"]];
     imageView.frame = CGRectMake(0,0,34,34);
     [titlev addSubview:imageView];
     UILabel *titleLAbel = [[UILabel alloc] initWithFrame:CGRectMake(32, -5, 276, 22)];
     titleLAbel.text = @"My Title";
     titleLAbel.textAlignment = UITextAlignmentCenter;
     titleLAbel.backgroundColor = [UIColor clearColor];
     titleLAbel.textColor = [UIColor whiteColor];
     titleLAbel.font = [UIFont fontWithName:@"Helvetica-Bold" size:16];
     [titlev addSubview:titleLAbel];
     UILabel *titleLAbel2 = [[UILabel alloc] initWithFrame:CGRectMake(32, 17, 276, 22)];
     titleLAbel2.text = @"My Subtitle";
     titleLAbel2.textAlignment = UITextAlignmentCenter;
     titleLAbel2.backgroundColor = [UIColor clearColor];
     titleLAbel2.textColor = [UIColor whiteColor];
     titleLAbel2.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
     [titlev addSubview:titleLAbel2];
     self.navigationItem.titleView = titlev;
comments powered by Disqus


Link to this snippet:

Download to Code Collector

To use the direct link to your snippet on either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 749
Date Added: 2009-03-02 11:19:39
Last Modified: 0000-00-00 00:00:00

Web Analytics