I am adding image to navigation bar it works fine but when i want to add title
self.title=@\"Activity\";
it does not show anything
Instead of add Image in UINavigationBar
, set background Image using bellow code..
UINavigationBar *navBar = [[self navigationController] navigationBar];
UIImage *backgroundImage = [UIImage imageNamed:@"Nav.png"];
[navBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
and then set Title like bellow...
self.title=@"Activity";
UPDATE
if ([navBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)])
{
[navBar setBackgroundImage:[UIImage imageNamed:@"Nav.png"] forBarMetrics:UIBarMetricsDefault];
}
else
{
UIImageView *imageView = (UIImageView *)[navBar viewWithTag:1];//any tag
if (imageView == nil)
{
imageView = [[UIImageView alloc] initWithImage:
[UIImage imageNamed:@"Nav.png"]];
[navBar insertSubview:imageView atIndex:0];
[imageView release];
}
}
self.title=@"Activity";