简体   繁体   中英

Xcode 8 constraints

I was coding in swift on the latest version of Xcode (as of 12/1/17). Since I'm new to coding in swift, I was unable to figure out a way to make my app compatible for all screen sizes. While building the app, my "View as" was set as iPhone SE. Now when I try running the program in another screen size, the size of the buttons, textfields and labels aren't in proportion. I found others with the same problem but none were able to answer my problem in a manner that I'd understand. This is one of the many frames on my storyboard that seems to be having the problem. I tried to click on the "Reset to suggested constraints" button but that only seemed to mess up the screen. It would be helpful if you'd be able to help me with this specific frame.

Xcode 8 provide efficient way to use autolayout.

You can check the video also. This works for me fine.

https://youtu.be/lx1NRHRMwUg

Whenever I have run into layout problems, I always find it easiest to delete them all, and start again. If you leave some in place, and start trying to fix others it can be very hard to tell what's going on.

The key thing with constraints is to keep it simple. If you only have 6 labels which are all in one column, then you can set the constraints for the first one (Displacement) in your example - make sure you're happy with the positioning, and then align all of the others to have the same leading edge, and give them Top & Bottom space constraints . This means if you decide to move them all out from the edge, you only have to change one.

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