title: NSView Contraints - How can I force the aspect ratio of a subview to stay constant?
body: <p>Having trouble implementing the following:</p>
  
  <pre><code>+-------------------+
  |                   |
  |                   |
  |     RESIZABLE     |
  |                   |
  |      NSVIEW       |
  |                   |
  |                   |
  |                   |
  |                   |
  |                   |
  |                   |
  |                   |
  |                   |
  |                   |
  |+-----------------+|
  ||                 ||
  ||     STATIC      ||
  ||                 ||
  ||     SUBVIEW     ||
  ||                 ||
  |+-----------------+|
  +-------------------+
  </code></pre>
  
  <p>Where the aspect ratio of the subview must stay constant (as the user changes the width of the resizeable view).</p>
  
  <p>I'd like to do it using constraints, so far I've got:</p>
  
  <pre><code>//This is a snippet of the resizable view class
  
  [self addConstraint:[NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:subview attribute:NSLayoutAttributeWidth multiplier:1 constant:0]];
  [self addConstraint:[NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:subview attribute:NSLayoutAttributeBottom multiplier:1 constant:0]];
  
  //This is a snippet of the subview class
  
  [self addConstraint:[NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeWidth multiplier:aspectRatio constant:0]];
  </code></pre>
  
  <p>The frame of the resizable view is initially set. In this case it would make sense not to set the frame of the subview? At the moment, the main view just seems to disappear - it starts width a width of zero.</p>
  
  <p>How should I go about this - I'd love to use constraints if possible!</p>