Skip to content

Commit cd03ca7

Browse files
committed
Change constraint to be inequality
In case the cell is too tall, better to have the extra space go here.
1 parent 47c184e commit cd03ca7

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

TableViewCellWithAutoLayout/TableViewController/TableViewCell.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ class TableViewCell: UITableViewCell
6262
titleLabel.autoPinEdgeToSuperviewEdge(.Top, withInset: labelVerticalInsets)
6363
titleLabel.autoPinEdgeToSuperviewEdge(.Leading, withInset: labelHorizontalInsets)
6464
titleLabel.autoPinEdgeToSuperviewEdge(.Trailing, withInset: labelHorizontalInsets)
65-
66-
bodyLabel.autoPinEdge(.Top, toEdge: .Bottom, ofView: titleLabel, withOffset: labelVerticalInsets)
67-
65+
66+
// This constraint is an inequality so that if the cell is slightly taller than actually required, extra space will go here
67+
bodyLabel.autoPinEdge(.Top, toEdge: .Bottom, ofView: titleLabel, withOffset: labelVerticalInsets, relation: .GreaterThanOrEqual)
68+
6869
UIView.autoSetPriority(1000) {
6970
self.bodyLabel.autoSetContentCompressionResistancePriorityForAxis(.Vertical)
7071
}

0 commit comments

Comments
 (0)