Collection view cells can be customized in many ways, including the size of the cells. There are multiple places to control the size of cells, and in order to provide even spacing between cells you'll need to write some code to specify that. See how here!
- [Instructor] To put it nicely,…our collection view isn't very nice to look at.…There's this big gap of space in the middle.…When you create a collection view,…you often want to have a uniform amount of space…between the different objects.…You also might want to have a certain number…of items per row.…Let's take a look at how to do that.…I'll head over to Xcode and stop the running app…and then head over in CollectionViewController.swift.…Inside of here, I'm going to delete all the comments…in viewDidLoad and I'm going to create an if statement…to reference the collection view's layout.…
The layout is an object that controls the size of the items…and spacing between items.…If let layout equal collectionView.collectionViewLayout…and we need to cast this as a UICollectionViewFlowLayout.…The reason we need to cast it is…because a collectionViewLayout data type,…as we can look inside of quick help,…is of the type UICollectionViewLayout,…but our collection view is using the flow layout,…which is specified inside of our storyboard.…
- Alert controllers and actions
- Sliders, progress bars, and switches
- Creating UI elements with code
- Displaying web content with Safari view controllers and WKWebView
- Creating collection view controllers
- Creating tabbed apps
- Publishing your app with App Store Connect
Skill Level Beginner
1. Master Views
2. Display Web Content
3. Collection Views
4. Multiview Templates
Customize a table view cell4m 18s
5. Publish an App
Next steps3m 28s
- 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.