Learn how to make your apps work on any device size in our Beginning Auto Layout course. Covers autoresizing masks, stack views, constraints, and more.
Is there a way I can continue watching the previous version of this series?. I was watching âIntro to Auto Layout Part 7: UILayoutGuide and NSLayoutAnchorâ, but now I canât find it here. Thank you for the update but I really want finish what I started.
Hey guys! Good point, hadnât considered the case where people were in the middle of the old series :]
Iâve re-listed them on the site temporarily; please finish watching when you can, weâll probably be taking them down again in a few weeks to prevent people from stumbling upon the old courses instead of the new/shiny/updated one. I hope that helps! :]
Thanks for the course and tying the concepts together. Itâs been very confusing to say the least. Can you clarify one last thing⊠It looked like the direction was moving towards adaptive layout. Now I see the tutorials are gone on it, and Iâm not sure I even see it in Xcode. Could you briefly describe it, and when you would use it over auto layout? This is a big learning and time investment. I would rather refactor my apps to the correct techniques then finding out there was a preferred way after the fact.
Good question. The old series on Adaptive Layout is back temporarily and the âMastering Auto Layoutâ series that is coming soon will explain it also, but generally speaking adaptive layout builds on top of auto layout, so you can start there and then add support for size classes (the core concept of adaptive layout). Auto layout will handle the minor adjustments between screen sizes and different environments, and then adaptive layout will handle the major changes between environments.
I do see your new tutorial and the old adaptive layout tutorial. I have an app thatâs been released and I used constraints for the whole thing. Your Auto Layout tutorial really clarifies many of the things I could have done to make things easier. Iâll watch it again or maybe more for the finer points, and then itâs off to refactoring for me! Thanks for the excellent work.
Iâm currently working on Beginning Auto Layout and the copyright label doesnât
center on any devices larger than the iPhone 7 using the suggested constraints.
It appears to center on the iPhone 7 but if you display the label on an iPhone 7 plus or
larger device, itâs off center to the left.
It works on all devices if I do the following:
If I select the âAlignâ icon and choose âalign horizontallyâ.
Select the âAdd new constraintsâ icon and choose the bottom spacing to
nearest neighbor (20) and choose âwidthâ and âheightâ and add 3 constraints,
then the label text centers at the bottom on every device.
I also did an âAuto Shrinkâ of the text and scaled it to 0.5.
The challenge with labels is that it can be hard to see what their actual frame is. The suggested constraints will cause the label to stretch the full width of the device (minus some spacing on each side). If you set the alignment of the label to centered, the text will be centered in the label - which is the full width of the device. But if the alignment is left at the default, left alignment, then the label will stretch on larger devices, but the text wonât move from its spot on the left.
I went back and looked at the label and realized that I hadnât selected âcenter alignmentâ in the attributes
inspector. By selecting âcenter alignmentâ and following your steps, it now works and aligns properly on all devices.
Iâm finding that you have to be careful about adding constraints because you can end up adding more
constraints then you need to correct constraints you didnât need in the first place!
Also, is this the proper place to post any and all questions about this video course?