6

Coming from the Android world, I'm trying to create my first IOS app in swift. Actually stuck to build interfaces that are adpative to all screen sizes from Iphone 5s to Ipad 12.9". Autolayout works well except that I can't find how to easily adjust font size and margins for each screen sizes. Maybe I've missed or miss-understood something in my research but my question is : How can I have big margins/font sizes on big screens and smaller margins/font sizes on smaller screens ? Is it possible to have like a constant for a margin for each device or range of screen size in one place so I can easily change it ?

Update : I forgot to mention that I also tried variations on constraints and font size but theres just a few options between "regular" and "compact" and if you need to change a margin you have to change it on all your elements it's seems crazy..

In Android there's a dimension xml file by each screen size/resolution you want where you can have contants and assign them to each element you want. I can't figure out the logic behind IOS here

Thanks in advance

Abel Hamilton
  • 73
  • 1
  • 6
  • Major up vote on this. What I do? Really bad, I know... I need all the space I can for iPhone SE so my minimum font size is 10 (I believe 1 point under what Apple recommends) and based on the screen's bounds (and orientation) move it up to 15. Not a good thing to do. Margins are accomplished by auto layout, size classes, and traits. A parameter of pretty much all layout constraints is **constant** and **multiplier**. As it sounds like you already know, these impact layout - not font size. –  Jan 10 '17 at 02:27
  • set your label's auto layouts properly and do this label.adjustsFontSizeToFitWidth = true, see whether it helps – bubibu Jan 10 '17 at 02:58
  • Yes I already tried that but there's nothing to adjust since I have enough width to display a big font size. Like when I center a title horizontally and add a top space constraint. But maybe my constraints are wrong..? – Abel Hamilton Jan 10 '17 at 14:26
  • @AbelHamilton did you get right solutions? I am still searching – user1629977 Jul 12 '17 at 07:40
  • Unfortunately no.. I end up using variations on constraints trying to find a compromise between each resolutions. – Abel Hamilton Oct 22 '17 at 11:46

0 Answers0