I'm trying to stretch an image from the very left of the view to the very center. I tried pinning constraints using left 0, bottom 0, and right 300, but it doesn't exactly goto the center. Any ideas?
See Question&Answers more detail:osI'm trying to stretch an image from the very left of the view to the very center. I tried pinning constraints using left 0, bottom 0, and right 300, but it doesn't exactly goto the center. Any ideas?
See Question&Answers more detail:osAssuming 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.
Align
-> Horizontally center in container
Size Inspector
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.