简体   繁体   中英

iOS - Autolayout/Size classes for buttons

I'm a bit confused about when to use autolayout and/or size classes for certain situations. On my initial view I have 2 buttons, one "continue with facebook" and one "register via email", stacked vertically. I initially set these to have around 70 height and 18pt font, and it looks great on the newer phones, but on the smaller ones they look enormous and combined (with spacing) end up taking up almost half the screen.

So my first thought was to make the buttons a percentage height of the main view or a subview, but things just started getting really complicated really fast: do I use percentages for the margins and spacing as well? Where does it end? It's a lot of calculations.

But I also don't see how it would be useful to use size classes here, since my app is only in portrait mode, and I can't really target say iPhone 5 vs iPhone 6 in that way.

So do I have to bite the bullet and use percentages to get nice looking buttons on all screens, or should I just suck it up and have really fat ones with a big font on the now less-used phones? And when it comes to font size, is there a generally accepted standard set of sizes (for headers and body text, for example) that looks good on all phones?

did you try use an aspect ratio constraint? if you use that then keep the distance from the edges fixed and it should squash proportionately for the different screen sizes

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