Reputation: 1689
I have the following view layouted with autolayout.
--------
+
--------
The plus icon is centered vertically on the cell. This should be different when a second icon appears as you can see on the following image:
--------
+
X
--------
I this case both icons together should be alligined vertically centered with a space of 5 between them.
I create my constraints in code no interface builder or Storyboard.
How can I achieve this with autolayout?
Upvotes: 0
Views: 45
Reputation: 2413
It's quite simple, but you need some code
for example
{
if (cell.secondView.hidden == true) {
// someConstraint - is your align constrain, which you can create throw IB
cell.someConstraint.constant = 0;
}
else
{
// note 'minus' - to move first view up
cell.someConstraint.constant = -cell.secondView.frame.height
}
}
Upvotes: 1