Learn how to code a pin constraint and a size constraint.
- [Instructor] You've turned off the automatic mode…for making constraints…and it's time to start adding your own.…You'll start with pins…and then work with the lines and sizes.…For pins, I'll make the image a background,…and place the label 40 points from the top leading space.…You'll add a constraint using the init method…of NSLayoutConstraint.…Since we needed an array, you'll make it…an element of an array, then add as the array.…To pin the image view to the top, for example,…let's do this.…
Go to your imageview.layout where it says…transalatesAutoresizingMaskIntoConstraints = false,…give yourself some space,…and right under there, type in constraints…+= and then .…Inside the brackets, add the constraint using…NSLayoutConstraint.init.…And you'll see there's two versions of this.…
One has a whole bunch of parameters…and one has none.…You need the one with all the parameters there.…And you'll see that it's a bit of a monster.…But it's actually not too bad,…especially if you put that notation comment in first.…Let's fill this one out and I'll show you.…
- 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.