Satchie
Satchie

Reputation: 21

Image aspect ratio swift ios

So, I'm learning iOS Swift. I'm going by some tutorials, and I'm stucked at image positioning.

I'm trying to figure out how uploaded picture is rescaled and positioned.Since I cannot post the screenshot, image that should be shown in my simulator as whole, I can only see like 25% of the picture. Should I change something in Attributes or in Size Inspector?

What I did so far (clearly wrong), was setting Intrinsic Size field -> select Placeholder, w/h = 320.

Then, I pinned and selected Aspect Ratio.

Any help, please? Thanks.

Upvotes: 2

Views: 2842

Answers (1)

Chris Slowik
Chris Slowik

Reputation: 2879

If you're asking how to make sure an image fills a UIImageView:

myImageView.contentMode = UIViewContentMode.ScaleAspectFill

You may also need to set constraints if you placed your image view in interface builder. enter image description here

It's not entirely clear from your question how you want it positioned, but hopefully these get you on the right path.

Upvotes: 2

Related Questions