简体   繁体   中英

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.

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. 在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM