title: Adding autolayout constraints to navigation controller programmatically
body: <p>I am trying to add constraints to a UI label I added on a navigation bar. The UI label shows a running timer</p>
  
  <p>Here is my code,</p>
  
  <pre><code>self.label = [[UILabel alloc] initWithFrame:CGRectMake(550, 15, 150, 14)];
  self.label.text = @"Label";
  [self.label setTranslatesAutoresizingMaskIntoConstraints:NO];
  [self.navigationController.navigationBar addSubview:self.label];
  
  [self.navigationController.navigationBar addConstraint:[NSLayoutConstraint constraintWithItem:self.label
                                                         attribute:NSLayoutAttributeTrailing
                                                         relatedBy:NSLayoutRelationEqual
                                                            toItem:self.navigationController.navigationBar
                                                         attribute:NSLayoutAttributeTrailing
                                                        multiplier:1.0f
                                                          constant:-20.0f]];
  </code></pre>
  
  <p>But I get the error 'Cannot modify constraints for UINavigationBar managed by a controller' when I run the app. </p>
  
  <p>How do I add this constraint?</p>