title: adding a border to a UIButton with auto-layout
body: <p>I have a custom <code>UIView</code>. In its <code>init</code> method I add a button and would like to add a top red border. I am trying to also do this with auto-layout but when running the console tells me that it can not satisfy all the constraints. What am I overlooking?</p>
  
  <pre><code>- (id)init {
      self = [super init];
      if (self) {
  
          _button = [[UIButton alloc] init];
  
          UIView *border = [[UIView alloc] init];
          border.backgroundColor = [UIColor redColor];
          [_button addSubview:border];
  
          [_button addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[border]|"
                                                                          options:0 metrics:0 views:NSDictionaryOfVariableBindings(border)]];
          [_button addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[border(1)]"
                                                                          options:0 metrics:0 views:NSDictionaryOfVariableBindings(border)]];
          [self addSubview:_button];
  
          [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_button(35)]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_button)]];
          [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_button(35)]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_button)]];
  
      }
      return self;
  }
  </code></pre>
  
  <p>This is the console message: </p>
  
  <pre><code>Unable to simultaneously satisfy constraints.
  Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
  (
      "&lt;NSLayoutConstraint:0x79f73ce0 H:|-(0)-[UIView:0x79f72ec0]   (Names: '|':UIButton:0x79f72900 )&gt;",
      "&lt;NSLayoutConstraint:0x79f73d10 H:[UIView:0x79f72ec0]-(0)-|   (Names: '|':UIButton:0x79f72900 )&gt;",
      "&lt;NSLayoutConstraint:0x79f73b40 H:[UIButton:0x79f72900(35)]&gt;",
      "&lt;NSAutoresizingMaskLayoutConstraint:0x79f327c0 h=--&amp; v=--&amp; UIView:0x79f72ec0.midX ==&gt;"
  )
  
  Will attempt to recover by breaking constraint 
  &lt;NSLayoutConstraint:0x79f73d10 H:[UIView:0x79f72ec0]-(0)-|   (Names: '|':UIButton:0x79f72900 )&gt;
  </code></pre>
  
  <p>Thanks</p>