Reputation: 2312
I'm using autolayout in IB and I have 2 labels within a container view. Both labels are "Size to Fit Content" since the strings lengths will vary.
I would like the labels separated by a fixed distance and I would like the combination of "Label 1---fixed distance---Label 2" centred horizontal within the containing view.
I tried selecting both labels at once and adding the "Horizontal Center in Container" constraint, but this appears to centre both textfields independently not as a group.
Upvotes: 1
Views: 749
Reputation: 618
A solution to this is considered in stanford university lectures on ios 7.It works beautifully.Attached here that solution. (Here sdfssfg... thing is label1 and efsdfg.... thing is label2)
Upvotes: 0
Reputation: 5655
You can do this by placing the labels inside a container view. Each label is flush against the edges of the container, and the container is centered in your custom view.
Upvotes: 3