From the course: iOS Development: Auto Layout Programmatically

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Anchors and the safe area

Anchors and the safe area - iOS Tutorial

From the course: iOS Development: Auto Layout Programmatically

Start my 1-month free trial

Anchors and the safe area

- You've just made your first auto-layout code. We are ready to run. Change your simulator to the iPhone 10, build, and run. When the list appears, select French toast. The French toast image appears as the full screen background but the label is cut off by the navigation bar. Press Command + left arrow to rotate the phone. The iPhone 10's notch now blocks the label. Let's explore what's going on here and how to prevent it. So far, we've been using the view's frame for the relationship to the sub views. However, there's several areas, like navigation bars, tool bars, and that iPhone 10 notch that can get in the way of those. There's a special area called the safe area that has boundaries that contextually take those into account. Let's add those to our project. First of all, rotate the phone back with the Command + right arrow and then stop the app. You can close up the console to give yourself some space. And now go to the label layout for top. So I'm gonna go to my label layouts…

Contents