I'm trying to create a back bar button programmatically, similar to the iOS 7 default back button. But when I add my back bar button to the navigation item. The Chevron plus is missing. How can I achieve this?
Asked
Active
Viewed 58 times
0
-
[for backbutton in navigationbar ios ][1] [1]: http://stackoverflow.com/questions/18870128/ios-7-navigation-bar-custom-back-button-without-title/22603128#22603128 – Paresh Hirpara Jun 16 '14 at 07:25
-
you can even try http://stackoverflow.com/a/16786531/2365064 – simply_me Jun 16 '14 at 09:39
1 Answers
0
UIImage* image_back = [UIImage imageNamed:@"leftarrow.png"];
CGRect backframe = CGRectMake(15, 5, 15,21);
UIButton *backbutton = [[UIButton alloc] initWithFrame:backframe];
[backbutton setBackgroundImage:image_back forState:UIControlStateNormal];
[backbutton addTarget:self action:@selector(Btn_back:)
forControlEvents:UIControlEventTouchUpInside];
[backbutton setShowsTouchWhenHighlighted:YES];
UIBarButtonItem *backbarbutton =[[UIBarButtonItem alloc] initWithCustomView:backbutton];
self.navigationItem.leftBarButtonItem=backbarbutton;
[backbutton release];
-(IBAction)Btn_back:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}

2014
- 119
- 1
- 1
- 13