Tricertops/KeepLayout

keepVerticalAlignTo != keepTopAlignTo + keepBottomAlignTo ??

Closed this issue · 2 comments

This is ok:

_tableView.keepTopAlignTo(self.keepLayoutView).equal = 0.0f;
_tableView.keepBottomAlignTo(self.keepLayoutView).equal = 0.0f;

This isn't (it make a constraint break after):

_tableView.keepVerticalAlignTo(self.keepLayoutView).equal = 0.0f;

Here the logs with keepVerticalAlignTo:

"<KeepLayoutConstraint:0x1700acf00 left margin inset of <KeepLayoutGuidesView 0x170194430> to superview <UIView 0x17019dc20> equal to 0 with required priority>",
"<KeepLayoutConstraint:0x1700acf60 right margin inset of <KeepLayoutGuidesView 0x170194430> to superview <UIView 0x17019dc20> equal to 0 with required priority>",
"<KeepLayoutConstraint:0x1700acd80 vertical center alignment of <UITableView 0x14e08c200> to <KeepLayoutGuidesView 0x170194430> equal to 0 with required priority>",
"<KeepLayoutConstraint:0x1700acd20 left inset of <UITableView 0x14e08c200> to superview <UIView 0x17019dc20> equal to 0 with required priority>",
"<KeepLayoutConstraint:0x1700aed60 right inset of <UITableView 0x14e08c200> to superview <UIView 0x17019dc20> equal to 0 with required priority>"
)

Will attempt to recover by breaking constraint 
<KeepLayoutConstraint:0x1700acd80 vertical center alignment of <UITableView 0x14e08c200> to <KeepLayoutGuidesView 0x170194430> equal to 0 with required priority>

So now I don't get if really it's suppose to exists a difference

_tableView.keepVerticalAlignTo(self.keepLayoutView)

will keep the center of _tableView aligned to self.keepLayoutView

keepTopAlignTo + keepBottomAlignTo could have the same result than keepHorizontalAlignTo + keepHeightTo

As @axelguilmin pointed out, . keepVerticalAlignTo() affects center alignement, so the size is not affected.

There is one more tricky thin, you shuould notice: When you vertically align two views, you align them along vertical axis, right? But this actualy causes the center X coordinate to change.

This .keepVerticalAlignTo() attribute, in fact, affects horizontal placement of the affected views. You may see this in your logs, that it mixes with left-right constraints. This is not a bug, this is actualy a feature :)