I am trying to add constraints to a UI label I added on a navigation bar. The UI label shows a running timer
Here is my 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]];
But I get the error 'Cannot modify constraints for UINavigationBar managed by a controller' when I run the app.
How do I add this constraint?