Auto Layout constraints can be added with code just like in a storyboard. The concept is simple—pin an edge of one user interface object to the edge of another. See how it all works in this video.
- [Tutor] One of the most important tools you can have,…when you're creating user interface elements with code…is understanding how auto layout works in code.…So what we're going to do is remove this line of code,…that sets the frame, when we're using auto layout,…that line doesn't matter anyway.…We need to make a slight modification to our label…to say that it's going to use auto layout.…Underneath our declaration of the label object on line 15,…I'm going to call…label.translatesAutoresizingMaskIntoConstraints…and what this says is it's a true or false or Boolean value,…that determines whether the view's autoresizing mask…is translated into auto layout constraints,…so what happens is if this is true, which it is by default,…then XCode automatically provides…auto layout constraints for you and what you want to do…is provide your own auto layout constraints.…
So we need to set this equal to false,…that's step one, then we add the constraints,…which we're going to do after the object…is added as a subview and that's important,…
- Installing and using Xcode
- Working with storyboards
- Working with UI objects and events
- Resizing objects and layouts dynamically
- Coding UI objects such as buttons
- Loading and displaying data in table views
- Testing your iOS app
Skill Level Beginner
1. Xcode Fundamentals
2. Core Skills
3. Responsive UI Design
4. Coding UI Objects
5. Table Views
6. App Flow and Testing
Next steps1m 8s
- 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.