Initializes and returns a newly allocated collection view object with the specified frame and layout.


init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout)



The frame rectangle for the collection view, measured in points. The origin of the frame is relative to the superview in which you plan to add it. This frame is passed to the superclass during initialization.


The layout object to use for organizing items. The collection view stores a strong reference to the specified object. Must not be nil.

Return Value

An initialized collection view object or nil if the object could not be created.


Use this method when initializing a collection view object programmatically.

This method is the designated initializer.

See Also

Initializing a Collection View

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software