简体   繁体   中英

Center 4 Images and maintain aspect ratio

Center 4图片

I cannot figure out how to get these images to centre. I like how I got them resizing accordingly for each device but would like to have them sit in the centre. I feel like I'm missing something super obvious but after a week of daily 1-2 hour sessions of trying... I give up.

If the link (Centre 4 Images) to my screenshot works, you can see they are fitting to each device just fine, only not centred.

** The images left to right are 1, 2, 3, 4.

Put the imageviews (1,2,3,4) inside a UIView (say ContentView) and give it two constraints - Top space to container, and Center horizontally in container. I'm assuming that you're imageViews are set up in such a way (having height, and bottom and top space to container constraints) that they would provide the height of ContentView.

That would help you center ContentView containing all the four images.

Hope that helps. Let me know if that works for you.

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