Possible Duplicate:
Custom UINavigationBar’s backButton?
I want to add custom button as left UIBarButtonItem. I have used following code
UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"menu.png"] style:UIBarButtonItemStylePlain target:self action:@selector(showMenu:)];
self.navigationBar.leftBarButtonItem = menuButton;
This does not show button but i can click & selector is called properly.
I also tried following way:
UIButton *menuButton = [UIButton buttonWithType:UIButtonTypeCustom];
[menuButton setImage:[UIImage imageNamed:@"menu.png"] forState:UIControlStateNormal];
[menuButton addTarget:self action:@selector(showMenu:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barMenuItem = [[UIBarButtonItem alloc] initWithCustomView:menuButton];
self.navigationItem.leftBarButtonItem = barMenuItem;
This shows the button & also clickable but button width is equal to default back button width. My Button image width is less than default back button image. So it centers the image in button with elongated width.
Any help is appreciated.
Sayali