title: Get frame of a view after autolayout
body: <p>I have a method:</p>
  
  <pre><code>- (void)underlineTextField:(UITextField *)tf {
      CGFloat x = tf.frame.origin.x-8;
      CGFloat y = tf.origin.y+tf.frame.size.height+1;
      CGFloat width = self.inputView.frame.size.width-16;
      UIView *line = [[UIView alloc] initWithFrame:(CGRect){x,y,width,1}];
      line.backgroundColor = [UIColor whiteColor];
      [self.inputView addSubview:line];
  }
  </code></pre>
  
  <p>That underlines an input <code>UITextField</code>; The textfield has a width that changes depending on the screen width (nib autolayout).</p>
  
  <p>I have tried using</p>
  
  <pre><code>[self.view setNeedsLayout];
  [self.view layoutIfNeeded];
  </code></pre>
  
  <p>and</p>
  
  <pre><code>[self.inputView setNeedsLayout];
  [self.inputView layoutIfNeeded];
  </code></pre>
  
  <p>before I call this method with no change in result. the resulting line is much wider than the UITextField (it matches the original size in the Nib).</p>
  
  <p>I just want the resulting frame of the UITextField in question after being processed by the autolayout</p>
  
  <p>SOLUTION: (using 'Masonry' Autolayout)</p>
  
  <pre><code>- (UIView *)underlineTextField:(UITextField *)tf {
      UIView *line = [[UIView alloc] initWithFrame:CGRectZero];
      line.backgroundColor = [UIColor whiteColor];
      [self.inputView addSubview:line];
      [line mas_makeConstraints:^(MASConstraintMaker *make) {
          make.centerX.equalTo(tf.mas_centerX);
          make.width.equalTo(tf.mas_width).with.offset(16);
          make.height.equalTo(@1);
          make.top.equalTo(tf.mas_bottom);
      }];
      return line;
  }
  </code></pre>