Rahul Mandalkar
Rahul Mandalkar

Reputation: 87

How to set labels text align to top UITableViewCell in iOS

I have tableViewCell which contain two labels with title and subtitle .Both have numberOfLine 0 with sizeToFit in cell class.But if text of one them is less then label text with less one, comes at center as

mismatched

Cell height is base on Label text size and if both Label text have same number of line then it appear good . So i want text of both label align to top.Cell height should be base of text of Label with more number of line.

Upvotes: 0

Views: 347

Answers (1)

Mike Atkins-Spelling
Mike Atkins-Spelling

Reputation: 524

This can be achieved in auto layout by setting the bottom labels constraint to >= rather than just = to the bottom of the cell in the xib. That way it should automatically fill the least amount of space so that text vertical alignment is no longer an issue.

Upvotes: 1

Related Questions