Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: Navigation bar with images for buttons

I would like to create a NavigationBar with images as buttons on the right side of the NavigationBar.

Something like below Snapshot

enter image description here

How can I achieve this?

like image 717
James Harpe Avatar asked Oct 29 '12 13:10

James Harpe


2 Answers

Hope This Helps

viewController.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourimage.png"]];
UIBarButtonItem * item = [[UIBarButtonItem alloc] initWithCustomView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourimage2.jpg"]]];    
viewController.navigationItem.rightBarButtonItem = item;    
like image 77
Vishnu Avatar answered Sep 20 '22 19:09

Vishnu


Here the Code, Just call below Methods From viewDidLoad method

  - (void)addCustomButtonOnNavBar
  {
   UIBarButtonItem * item1= [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"passImageNmae1"] style:UIBarButtonItemStylePlain target:self action:@selector(yourButtonAction1)];
   UIBarButtonItem * item2= [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"passImageNmae2"] style:UIBarButtonItemStylePlain target:self action:@selector(yourButtonAction2)];
  NSArray * buttonArray =[NSArray arrayWithObjects:item1,item2 ,nil];

   self.navigationItem.rightBarButtonItems =buttonArray;

  }
like image 40
Kamar Shad Avatar answered Sep 19 '22 19:09

Kamar Shad