Florian Schaal
Florian Schaal

Reputation: 2660

set background image navigation bar

So I am try to set a background image for a navigation bar in MonoTouch. The image will be the same everywhere. How would i do this?

In the viewdid load: NavBar.SetBackgroundImage(UIImage.FromFile ("btn-title-bar.png"));

doesn't work.

Upvotes: 2

Views: 4485

Answers (4)

Kirit Modi
Kirit Modi

Reputation: 23407

Try this below code.

   UIImage *image = [UIImage imageNamed: @"[email protected]"];
   UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
   imageView.frame = CGRectMake(0, 0, 320, 44);
   [self.navigationController.navigationBar addSubview:imageView];

Upvotes: 1

Rameshwar Gupta
Rameshwar Gupta

Reputation: 791

if you want to put different images on every page then write this method in view did load on every page..

UIImage *image = [UIImage imageNamed: @"logo.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
self.navigationItem.titleView = imageView;

and if u want single image on every page then write this code in delegate.m.

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"logo.png"]

forBarMetrics:UIBarMetricsDefault];

Upvotes: 0

Blounty
Blounty

Reputation: 3358

In c# land that is:

UINavigationBar.Appearance.SetBackgroundImage (UIImage.FromFile ("btn-title-bar.png"), UIBarMetrics.Default);

Upvotes: 2

parilogic
parilogic

Reputation: 1179

Try

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"btn-title-bar.png"] forBarMetrics:UIBarMetricsDefault];

Upvotes: 3

Related Questions