Assuming that you know how to set the left, top, bottom, height constraints I will explain you how to set the right constraint, which will cause the imageView to span from the left to the center of the screen. Setting any width constraint will not work, because the width depends is different on every device.
- click your imageView
- choose
Align
-> Horizontally center in container
- click on the newly created constraint
- choose the
Size Inspector
- Change the
First Item
from Center X
to Trailing
The "standard" Horizontally center in container
causes the Center X
of your view and its super view to be aligned. If you change the First Item
to Trailing
instead of Center X
you therefore align the trailing edge / right of your view to the centerX of your superview.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…