title: Programatic autolayout, constraints and UIView runtime
body: <p>In reading the View Programming Guide from Apple it is apparent they have not updated it for constraints.  So a couple of questions:</p>
  
  <ol>
  <li><p>Many posts here talk about NOT using -initWithFrame when initializing a new UIView or setting it to CGRectZero or some equivalent.  How would you handle this then?:</p>
  
  <pre><code>-(id)initWithFrame:(CGRect)frame
  {
      self = [super initWithFrame:frame];
      if (self){
  
      //Set up rounded rectangle ivar
      CGRect frame = [self bounds];
      CGFloat radius = frame.size.height / 2;
      _rectPath = [UIBezierPath bezierPathWithRoundedRect:frame cornerRadius:radius];
      } 
  }
  </code></pre>
  
  <p>and then putting the drawing code in the drawRect:.  I have found that it won't init properly    without a frame.  (Obviously, I'm initing this UIView and immediately setting constraints but no frame immediately).  This code set's frame = (0,0,0,0) because constraints haven't been computed yet.</p>
  
  <p>If we don't put this code in init where would we put it?  Also, I thought it was good practice to init all our stuff we needed in the view in init.</p>
  
  <p>So this leads to question...</p></li>
  <li><p>When is -updateConstraints called in the runtime cycle and when does the view compute it's bounds using those constraints?  I have noticed that the view really doesn't know what it's bounds are until after -layoutSubviews.  Is there another place before this that the UIView knows it's bounds if it has only been set with constraints?</p></li>
  </ol>
  
  <p>Sorry about all the questions, but they all kinda seem connected.  Thanks for the looks.</p>