Make a decision tree to layout devices correctly.
- [Instructor] You know the device can tell…which way the layout of view with the traits.…Now let's set up a decision tree…to lay out the view differently…depending on your orientation and device.…The documentation tends to use width and height,…while the properties are horizontal and vertical.…We'll use our widthSizeClass and heightSizeClass…to figure out all this stuff.…There are three or four configurations for size class.…I'll start with the basic three,…assuming an iPhone Plus, X, like any other phone.…iPad is always regular in both size classes,…so a good way to start is to look for an iPad.…
For now, I'm just gonna print it to the console.…So, underneath all the rest of this,…I'm going to put in an if statement,…if…the widthSizeClass…is regular…and the heightSizeClass…is regular,…that's an iPad, so I'm gonna print…iPad.…
Now, in landscape, all iPhones are compact in height,…so I'm gonna add an else to this if statement…and I'm going to check for a heightSizeClass of compact,…heightSizeClass…equals compact.…Then you've got yourself an iPhone landscape.…
- When and why to use Auto Layout programmatically
- Creating constraints in Swift
- Resolving errors in Auto Layout
- Using the safe area
- Working with the Visual Format Language
- Adding a stack view
- Harnessing the power of inequalities and priorities in constraints
- Understanding traits and size classes
Skill Level Intermediate
Learning LayoutTest for iOS Developmentwith Kyle Sherman1h 43m Intermediate
Designing iOS and Android Appswith Renata Phillippi1h 6m Intermediate
1. Basic Concepts in Auto Layout
2. Coding Constraints
3. The Visual Format Language
4. Stack Views
5. Advanced Layout
6. Size Classes
Next steps1m 42s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.