0

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
skyler
  • 742
  • 1
  • 10
  • 24

1 Answers1

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