Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Ilya Feynberg
Ilya Feynberg
2,567 Points

Completely lost on autolayout, constraints and screen designs. :(

I'm a bit stuck and any help would be greatly appreciated!

I'll give you a quick overview. I have designs for a screen that were built in sketch using an iphone 6 screen size, then redesigned to fit and look right for an iphone 5/5s/5c, and 6 plus as those are the only devices that I want to support.

But the design portion or implementing the designs for just one specific screen size is easy and I understand that part. Where am I'm lost completely, is how to implement a design in one view controller that looks the way that it should in all the screen sizes I designed for.

I've gone through more than a few auto layout and size class tutorials both here and elsewhere and not sure how I properly use them so that the app recognizes "this is an iphone 5, use these image sizing and placements instead, and this is an iphone 6 plus, use these" and so on.

Everything I've seen to this point regarding auto layout and constraints only use 1 set of numbers to judge distance from elements for example, but all screen sizes would have different distances.

What am I missing or not understanding? I know I'm looking at something improperly.

Thanks in advance for all help!

1 Answer

I may be wrong, but as far as I know, there isn't a way to use different values based on which model iPhone is running the app. It's a trick of using relative values (such as percents) rather than absolute values, and just tweaking those relative values so that they gel convincingly on all screen sizes.

In short, I think it's just a balancing act. Like I said, I'm not totally certain this is the case, but I haven't seen anything suggesting the contrary so far.

Ilya Feynberg
Ilya Feynberg
2,567 Points

Thanks for the quick response Alex, it's much appreciated! :)

I haven't personally seen or noticed percents yet when trying to work with constraints but rather absolute numbers. I'm just not understanding how people are getting those numbers and how they can work for each device.

I really hope it's not just a balancing act though, that could make it a nightmare to build an app that works and looks great across many devices.

Your answer gave me an idea to look into, thanks again Alex!

  • Ilya