1

How to align the trailing edge of the one view to the horizontal centre of the other view.

._____________
|1____________|
.______________________________
|2_____________________________|

I want something like above. I always want the view1 to the half of the width of the view2.

pnuts
  • 58,317
  • 11
  • 87
  • 139
nivea
  • 47
  • 8
  • Set the leading to be the same and the width of view1 to be 50% of the width of view2? – j.f. Sep 02 '15 at 16:48
  • Thanx for reply. But how to do this? – nivea Sep 02 '15 at 16:58
  • I got the solution from the following link. http://stackoverflow.com/questions/30814710/how-can-i-make-in-auto-layout-that-view1-height-will-be-3-7-view2-height – nivea Sep 02 '15 at 17:05

2 Answers2

3

Click both UI elements you want to align and align their trailing edges

enter image description here

Select one of the two elements and double click on the newly created constraint

enter image description here

Change the Edge of the item that you want to be bigger (in my case SecondItem) and set its edge to be CenterX

enter image description here

update the frames and voila

enter image description here

luk2302
  • 55,258
  • 23
  • 97
  • 137
1

Hold CTRL then click and drag from view1 to view2. Let go of the mouse click and a menu should pop up. Choose both "Left" and "Equal Widths".

Then click the edit button of the Equal Width constraint and change the multiplier to 0.5 (50%).

Multiplier

j.f.
  • 3,908
  • 2
  • 29
  • 42