简体   繁体   中英

Swift how to resize elements depending on screen size

I've got all my elements in the view and have added constraints to position them correctly on any device.

But when it's run on a 3.5 inch iPhone some of the bottom stuff is cut off and when it's run on a iPhone 6Plus there's a lot of extra space on the bottom.

How could I resize all the elements to look good on all devices?

This is a universal app to run on iPhone and iPad.

I guess you constraint an element as width equals 300...It's very bad for some elements that should fill (or fill percent of) the screen. I suggest you make percentage constraints. For example, make equal width to view, click Edit button and set Multipiler 0.6. It looks like this in storyboard: 在此处输入图片说明

设置两个约束(例如,拖尾和前导)并为图像设置宽高比,也许这会有所帮助。

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