Having trouble implementing the following:
+-------------------+
| |
| |
| RESIZABLE |
| |
| NSVIEW |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|+-----------------+|
|| ||
|| STATIC ||
|| ||
|| SUBVIEW ||
|| ||
|+-----------------+|
+-------------------+
Where the aspect ratio of the subview must stay constant (as the user changes the width of the resizeable view).
I'd like to do it using constraints, so far I've got:
//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]];
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.
How should I go about this - I'd love to use constraints if possible!