Reputation: 1876
I have a simple design question but can't seem to find the simplest answers.
Having say 10 UIViews aligned from top to bottom with no overlap. If I want to expand the height of one of them, how to I move the others so no overlapping occurs?
Here's my three thoughts, love to hear yours:
Have I forgotten anything obvious?
Regards
Upvotes: 0
Views: 59
Reputation: 2398
I would certainly go with (3) for a few reasons:
Yes, AutoLayout can be a bit more complex to work with at times, especially in the beginning, but I promise you: it's worth it in the long run.
Here's some code to get you started. The below constraints are for 5 views. The first UIView
will have a height of greater than or equal to myViewHeight
, which is defined below to be 20. The subsequent 4 views will be equal to myViewHeight
.
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[_myView(>=myViewHeight)][_myView(==myViewHeight)][_myView(==myViewHeight)][_myView(==myViewHeight)][_myView(==myViewHeight)]-|"
options:0
metrics:@{@"myViewHeight": @20}
views:NSDictionaryOfVariableBindings(_myView)]];
Upvotes: 1