title: How to change NavigationBar of NavigationController in every other controller based on requirement?
body: <p>In my app i have created a Custom UINavigationBar in which i have written different methods for customizing the UInavigationBar like navigation bar with title image, backbutton and signoff button some of them will only have two of these and some of them only title image. 
  I have to change the navigation bar based on which viewcontroller we are in.</p>
  
  <p>Here's my CustomUINavigationClass</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  typedef enum {
      simple = 1,
      back,
      signoff,
      both
  } NavBarChoices;
  
  
  NavBarChoices optionSelect;
  
  @interface CustomNavigationBar : UINavigationBar
  {
      UIBarButtonItem * menuButton;
      UIButton * showEditButton;
  }
  
  - (id)initWithFrame:(CGRect)frame andOption:(NavBarChoices)choice;
  @end
  </code></pre>
  
  <p>.m</p>
  
  <pre><code>#import "CustomNavigationBar.h"
  
  @implementation CustomNavigationBar
  
  - (id)initWithFrame:(CGRect)frame andOption:(NavBarChoices)choice
  {
      self = [super initWithFrame:frame];
      if (self) {
          // Initialization code
          NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"CustomNavigationBar"
                                                                owner:self
                                                              options:nil];
  
          if ([arrayOfViews count] &lt; 1){
              return nil;
          }
          optionSelect = choice;
          CustomNavigationBar *newView = [arrayOfViews objectAtIndex:0];
  
          self = newView;
  
      }
      return self;
  }
  
  
  // Only override drawRect: if you perform custom drawing.
  // An empty implementation adversely affects performance during animation.
  - (void)drawRect:(CGRect)rect
  {
  
      switch (optionSelect) {
          case 1:
              [self drawSimpleNavBar];
              break;
          case 2:
              [self drawWithBackOnly];
              break;
          case 3:
              [self drawWithSignOffOnly];
  
              break;
          case 4:
              [self drawWithBackAndSignOff];
              break;
  
          default:
              break;
      }
  
  }
  
  -(void)drawSimpleNavBar {
  
      self.tintColor = [UIColor whiteColor];
      self.backgroundColor = [UIColor whiteColor];
      UIImage *image = [UIImage imageNamed:@"title_logo.png"];
      [image drawInRect:CGRectMake(100, 13, 104, 20)];
  
      UIImage *menuImage = [UIImage imageNamed:@"menu_off.png"];
      showEditButton = [UIButton buttonWithType:UIButtonTypeCustom];
      showEditButton.bounds = CGRectMake(0, 0, menuImage.size.width, menuImage.size.height+10);
      showEditButton.frame = CGRectMake(2, 10, menuImage.size.width, menuImage.size.height);
      [showEditButton setImage:menuImage forState:UIControlStateNormal];
      [showEditButton setImage:[UIImage imageNamed:@"menu_on.png"] forState:UIControlStateSelected];
      [showEditButton addTarget:self action:@selector(showMenu) forControlEvents:UIControlEventTouchUpInside];
      [self addSubview:showEditButton];
  
  }
  
  -(void)drawWithBackOnly {
  
      self.tintColor = [UIColor whiteColor];
      self.backgroundColor = [UIColor whiteColor];
      UIImage *image = [UIImage imageNamed:@"title_logo.png"];
      [image drawInRect:CGRectMake(100, 13, 104, 20)];
  
      UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
      [backButton setTitle:@"Back" forState:UIControlStateNormal];
  
      [backButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
      backButton.frame = CGRectMake(0, 3, 80, 30);
      backButton.titleLabel.font = [UIFont boldSystemFontOfSize:12];
      [backButton sizeToFit];
      [backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
      [self addSubview:backButton];
  
  }
  
  -(void)drawWithSignOffOnly {
  
  }
  
  
  -(void)drawWithBackAndSignOff {
  
  }
  
  -(void)showMenu {
      NSLog(@"Clicked");
      showEditButton.hidden = YES;
      [showEditButton setImage:[UIImage imageNamed:@"menu_on.png"] forState:UIControlStateNormal];
  }
  
  
  @end
  </code></pre>
  
  <p>And i am calling this as in App Delegate :</p>
  
  <pre><code>navigationBar = [[CustomNavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 44) andOption:simple];
      UINavigationController * nav = [[UINavigationController alloc]initWithNavigationBarClass:[navigationBar class] toolbarClass:nil];
  
      self.viewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
      [nav setViewControllers:@[_viewController] animated:NO];
  
  self.window.rootViewController = nav;
  </code></pre>
  
  <p>Now i have a button in First view controller on click i want to push another view conroller which will sent a request to the CustomNavigationBar class to change the navigation bar for the same NavigationController.</p>
  
  <p>Please guide, currently i am trying to make changes to the viewDidLoad method of the new controller but the challenge is NavigationBar property of UINavigationController is readonly so can't assign new navigation bar to it or else i would have done something like this</p>
  
  <pre><code>CustomNavigationBar * navBar = [[CustomNavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 44) andOption:2];
  self.navigationController.navigationBar = navBar;
  </code></pre>
  
  <p>Please help.</p>
  
  <p>Thanks,</p>