Reputation: 325
Assume I have one big UIImageView that is set to a vector, and I want this ImageView to take up 90% of the screens width while maintaining it's aspect ratio, regardless of device, since it is a vector, resizing is not an issue. Height does not matter since I need it to just maintain it's aspect ratio, so long as it is 90% of the width of the screen. How can I do this in UIBuilder?
Upvotes: 5
Views: 2256
Reputation: 154711
Here is how to make an image width 90% of its superview:
UIImageView
to the Storyboard.multiplier
for the constraint to 0.9
.UIImageView
to itself and select Aspect Ratio from the pop-up. Set the multiplier
value of the resulting constraint to the desired value. You can use a ratio such as 3:4
or a floating point value such as 0.75
.UIImageView
to Scale To Fill, Aspect Fit, or Aspect Fill so that the UIImage
fills the UIImageView
.Upvotes: 10