Uicollectionview Layouts Kit

screenshot of Uicollectionview Layouts Kit

Custom layouts for UICollectionView with examples [iOS 12+].

Overview:

The uicollectionview-layouts-kit is a collection of custom layouts for UICollectionView in iOS. These layouts provide various design options and support both portrait and landscape UI orientations, as well as all iOS-related screen sizes. The project is meant for demonstration purposes and should not be used for commercial or proprietary projects due to the usage of assets taken from the web.

Features:

  • Perspective transformation: Reveal cell's content while scrolling up and down.
  • Automatic adjustment of contents: Fit the current screen.
  • Portrait orientation: Supports only iPhones.
  • Adjustable properties: Various layout properties can be changed.
  • Scalable: Can be adopted to support iPad and other screen sizes.
  • Stack layout: A layout where the collection view items are stacked on top of each other.

Programmatic Setup:

If you prefer the programmatic approach, set the instance of a layout using the following scheme:

let customLayout = CustomLayout()
collectionView.collectionViewLayout = customLayout

Storyboard/Nib Setup:

To set up the layouts via Storyboard/Nib, follow these steps:

  1. Find your Collection View in Xcode's visual editor.
  2. Select it and open the Attributes Inspector.
  3. Find and change the UI menu called Layout to Custom.
  4. Set the class to the one you wish to use.

In your view controller, provide a valid reference to the UIViewController from the Storyboard/Nib file where you overridden the default layout class.

For cases when you need to tell your custom layout what class is going to delegate the layout handling, use the following code:

customLayout.delegate = self

For cases when you simply need to change properties for custom layouts that were set via the visual editor, use the following code:

customLayout.property = newValue

If you use the Storyboard/Nib approach, consider creating an IBOutlet to the custom layout and directly set it up instead of casting the layout using the collection view reference.

Summary:

The uicollectionview-layouts-kit provides a collection of custom layouts for UICollectionView in iOS. It offers various design options, supports different screen sizes and orientations, and can be easily integrated into projects either programmatically or via Storyboard/Nib setup. It is important to note that the project should only be used for demonstration purposes and not for commercial or proprietary projects due to the usage of web-based assets.