insertSections(_:)
Inserts new sections at the specified indexes.
Declaration
func insertSections(_ sections: IndexSet)Parameters
- sections:
An index set containing the indexes at which you want to insert new sections. This parameter must not be
nil.
Discussion
This method tells the collection view to insert the specified sections and update itself. Always update your data source object before calling this method. Calling this method kicks off an update (and possible animations) to add the new sections. Specifically, the collection view asks the layout object for any updated layout attributes related to the new sections or any existing sections. If the layout attributes of any visible items changed, those changes are animated into place.
When inserting or deleting multiple sections and items, you can animate all of your changes at once using the performBatchUpdates(_:completionHandler:) method.