setting image to navigation top and ottom bars
-
13-09-2020 - |
Question
i am having rootview controller in my navigationn controller and if i want to set a image to my bottom bar and top bar in my root view controller using programmatically .. how to set it ? plz any bidy help me out
Solution
If you are looking to add an image to the bars, see this URL:
http://www.iphonedevsdk.com/forum/111227-post11.html
This demonstrates how to add a graphical "Info" button to a navbar, but the same principle applies with a UIImageView instead of a UIButton.
Here is the code snipplet from the link:
UIButton *btn=[[UIButton alloc] init];
[btn setImage:[UIImage imageNamed:@"info44.png"] forState:UIControlStateNormal];
[btn setImage:[UIImage imageNamed:@"info44_glowing.png"] forState:UIControlStateHighlighted];
[btn addTarget:self action:@selector(showAbout) forControlEvents:UIControlEventTouchUpInside];
[btn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 20)];
UIBarButtonItem *b=[[UIBarButtonItem alloc] initWithCustomView:btn];
self.navigationItem.rightBarButtonItem=b;
[b release];
[btn release];
Hope that helps!
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow