Create consistent sizing using metrics. Learn how to use margins to control spacing.
- [Instructor] You've used numbers to set spaces.…You can also use identifiers to set your numbers.…This makes for better documented code,…the use of properties and calculations,…and consistent constants for spacing.…You do all that with metrics.…Go ahead and stop the app.…Towards the top of the layout method,…you'll find the metrics dictionary you defined earlier.…If you look at the constraints,…they have a parameter called metrics.…
The constraints reads the metrics…dictionary to replace values.…I'll add two entries to the dictionary.…One with a key of panning of 10 points…and another with a key of margin of 20 points.…So, I'll type in, here, padding…in quotes for my key, and the value there will be 10.…And then I'll do a margin…and that'll be 20.…
Now, any place I use a number, I could use a metric.…I'll change all the constraint…strings to use these identifiers, instead.…So, for example, here I got a 15,…so I can make that, that's gonna be margin…and I've got a 10, here, I'll make that padding,…and I've got a 20, here, that…
- 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.