title: Dynamically change navigation bar color for ios
body: <p>I have multiple pages for each prototype cell in my ios app. I want the navigation bar color to change with each page. Here is the code I tried: </p>
  
  <pre><code>override func viewDidLoad() {
          super.viewDidLoad()
  
          self.view.backgroundColor = workout.color
          self.detailText.text = workout.workoutText
          self.title = workout.title
  
  
          self.navigationController?.navigationBar.barTintColor = workout.color
  
  
          self.navigationController?.navigationBar.backgroundColor = workout.color
  
          self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
  }
  </code></pre>
  
  <p>The color changes for the frst click but then remains the same no matter which page I click on even though the title, text and background color change correctly. If everything else changes, why doesn't the navigation bar color change? </p>