title: Determine if view is hidden or not and change button state programmatically
body: <p>I have three views and three buttons each button toggles the view (hidden = yes/no)</p>
  
  <pre><code>- (IBAction)switchOne:(id)sender {        
      [_firstPage setHidden:NO];
      [_secondPage setHidden:YES];
      [_thirdPage setHidden:YES];
  }
  
  - (IBAction)switchTwo:(id)sender {        
      [_firstPage setHidden:YES];
      [_secondPage setHidden:NO];
      [_thirdPage setHidden:YES];        
  }
  
  - (IBAction)switchThree:(id)sender {        
      [_firstPage setHidden:YES];
      [_secondPage setHidden:YES];
      [_thirdPage setHidden:NO];
  }
  </code></pre>
  
  <p>I want to set the background of the button depending if the view is hidden or not.</p>
  
  <p>I have tried this but without results:</p>
  
  <pre><code>if (_firstPage.hidden == NO)
  {
      UIImage *buttonImage = [UIImage imageNamed:@"currentPage.png"];
      [_pageOneButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
      [self.view addSubview:_pageOneButton];
  
  } else if (_firstPage.hidden == YES) {
      [_pageOneButton setBackgroundImage:nil forState:UIControlStateNormal];
  }
  </code></pre>
  
  <p>The <code>_pageOneButton</code> keeps the background even with the view hidden.</p>
  
  <p>I leave an image of the menu as is now:</p>
  
  <p><img src="https://i.stack.imgur.com/5YkgC.jpg" alt="menu-active"></p>
  
  <p>The point is: when Página 2 is active (hidden == NO) the Página 1 button should be without the background.</p>