I have three NSViews stacked on each other, and I want to be able to programmatically resize the middle one to stretch it vertically, moving the bottom one down by the same amount that the middle one stretches.
Here is an ASCII picture:
|--------------|
| 1 |
|-------------开发者_如何学运维-|
|--------------|
| 2 |
|--------------|
|--------------|
| 3 |
|--------------|
So basically I want to be able to stretch NSView 2 vertically so that the resulting picture would look like this:
|--------------|
| 1 |
|--------------|
|--------------|
| |
| 2 |
| |
|--------------|
|--------------|
| 3 |
|--------------|
What is the correct way to go about doing this? Thanks!
Edit: Here's a follow-up question...
How can I go from this:
|--------------|
| 1 |
|--------------|
|--------------|
| 2 |
|--------------|
|--------------|
| 2.5 |
|--------------|
|--------------|
| 3 |
|--------------|
To this:
|--------------|
| 1 |
|--------------|
|--------------|
| |
| 2 |
| |
|--------------|
|--------------|
| |
| 2.5 |
| |
|--------------|
|--------------|
| 3 |
|--------------|
The easiest way to do this is with autoresizing mask.
You can set the autoresizing mask programatically with
- (void)setAutoresizingMask:(NSUInteger)mask
Or in Interface builder.
In IB, the first view's autorisizing mask would be
The second :
The third :
Sounds like you either need an NSSplitView
or CHLayoutManager.
精彩评论