Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Autolayout: Align left edge of a UILabel with horizontal center in container?

So I'm trying to have a customized UITableViewCell that looks like the following:

See the second column of titles and how the left side of them are aligned with the center

And I'm trying to get the Detail labels to be left aligned and set the content hugging on the title labels higher.

So the challenge I have is that I want the left edge of the second column on Title cells to be aligned with the center of the whole view.

Is there a way to do that?

like image 653
P. Sami Avatar asked Nov 12 '13 20:11

P. Sami


1 Answers

Try using a couple of grouping views, one for each column. Pin the outer edges of each column view to the edges of the cell content view, then add an equal-widths constraint to the column views.

Once you have your containing column views in place, you can layout the labels inside each.

enter image description here

enter image description here

like image 142
lintmachine Avatar answered Oct 27 '22 08:10

lintmachine