# MagazineLayout: Fractional-Width Grid and List Layout for UICollectionView

> MagazineLayout is an Apache-licensed UICollectionViewLayout subclass from Airbnb that adds fractional-width columns, per-item self-sizing, pinned headers, and section backgrounds to UICollectionView on iOS and tvOS. It targets iOS 10 and requires cells and supplementary views to subclass its own base types.

**airbnb/MagazineLayout** — A collection view layout capable of laying out views in vertically scrolling grids and lists.

- Repository: https://github.com/airbnb/MagazineLayout
- Stars: 3,376 · Forks: 223
- Language: Swift
- License: Apache-2.0
- Published: 2026-09-23 · Updated: 2026-09-23 · Language: en
- Canonical page: https://hysenlabs.com/projects/airbnb-magazinelayout

## What MagazineLayout Adds Beyond UICollectionViewFlowLayout

UICollectionViewFlowLayout, the standard UICollectionView layout built into UIKit, supports fixed-size or uniformly estimated items in a single-axis grid. It does not allow per-item width fractions, per-section sticky headers, or section-level background views.

MagazineLayout is a UICollectionViewLayout subclass from Airbnb that adds these capabilities. An item's width is defined as a fraction of the available width, such as full width for a list-style cell, half-width for a two-column grid, or one-third width for a three-column grid. Height is determined by the content through self-sizing, so items in the same row can be different heights without requiring explicit size calculations. The README notes that this combination let the team build a variety of screens in the Airbnb app, including homes search, experiences search, wish lists, and trip details.

## Fractional Widths, Self-Sizing, and Per-Section Configuration

MagazineLayout uses a delegate protocol (MagazineLayoutCollectionViewDelegateLayout) to ask for layout attributes per item and per section. Width modes let you specify that an item should occupy the full width, one-half, one-third, or other fractions of the available space. Because items are sized by fractions rather than absolute points, the layout adapts to different screen widths and orientations without recalculating sizes.

Self-sizing works only in the vertical dimension. Horizontal size is always determined by the width mode, while height is computed from the cell's Auto Layout constraints after the layout sets the cell's width. Per-item self-sizing preferences let you mix self-sizing items and statically-sized items within the same collection view.

Section-level configuration options cover horizontal item spacing, vertical row spacing, section insets, and item insets, all set independently per section through the delegate. Section backgrounds can be toggled visible or hidden per section. Headers and footers can be configured as pinned (sticky) or non-pinned, and can also be shown or hidden per section. Customizable insert and delete animations apply to both items and supplementary views.

## Adding MagazineLayout via CocoaPods or Carthage

MagazineLayout requires iOS 10.0 or later (tvOS 10.0 or later), Swift 4 or later, and Xcode 10 or later.

To install with CocoaPods, add this line to your Podfile:

```swift
pod 'MagazineLayout'
```

Then follow the CocoaPods integration steps in the CocoaPods documentation. To install with Carthage, add this line to your Cartfile:

```swift
github "airbnb/MagazineLayout"
```

Then follow the Carthage integration tutorial. The README also notes that the repository includes a Package.swift file, indicating Swift Package Manager support, though the README does not document SPM integration steps directly.

An example app is available in `./Example/MagazineLayoutExample.xcworkspace`. The README states to use the `.xcworkspace` file rather than the `.xcodeproj` file, because the project file does not have access to `MagazineLayout.framework`.

## Setting Up the Collection View in Your View Controller

At the top of the file where you want to use MagazineLayout, import the framework:

```swift
import MagazineLayout
```

Create a `MagazineLayout` instance and pass it to `UICollectionView` on initialization:

```swift
let layout = MagazineLayout()
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
```

Add the collection view as a subview and constrain it with Auto Layout:

```swift
view.addSubview(collectionView)
collectionView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
  collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
  collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
  collectionView.topAnchor.constraint(equalTo: view.topAnchor),
  collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
```

With the collection view in place, register your cell and supplementary view types, set the data source, and set the delegate to an object conforming to `MagazineLayoutCollectionViewDelegateLayout`.

## The Subclassing Requirement and What It Means for Existing Code

MagazineLayout requires cells to subclass `MagazineLayoutCollectionViewCell` and supplementary views to subclass `MagazineLayoutCollectionReusableView`. The README cites shortcomings in UIKit as the reason for this requirement. These two types override `preferredLayoutAttributesFitting(_:)` to enable correct self-sizing within MagazineLayout's measurement pass.

For new projects, this is a straightforward requirement: create cell subclasses that inherit from `MagazineLayoutCollectionViewCell` rather than `UICollectionViewCell`. For projects with existing deep cell hierarchies or third-party cell components that inherit directly from `UICollectionViewCell`, switching to MagazineLayout means either refactoring those types or copying the `preferredLayoutAttributesFitting(_:)` implementation into them, as the README describes as an alternative.

This constraint is a genuine trade-off. The layout's self-sizing logic depends on having control over layout attribute fitting, and it uses subclassing to guarantee that. Projects where cell types cannot be changed will not be able to use self-sizing with MagazineLayout.

## Limitations: iOS 10 Minimum and One-Axis Self-Sizing Only

Self-sizing in MagazineLayout applies only in the vertical dimension. Horizontal size is always a fraction of the available width, not determined by content. This is by design for the column-based layout model, but it means items whose width should shrink to fit their content will not work as expected.

The deployment target of iOS 10.0 is a constraint for projects that have since raised their minimum to iOS 13 or later. Apple introduced UICollectionViewCompositionalLayout in iOS 13 as a built-in UICollectionViewLayout option that supports nested groups and sections with flexible sizing. Engineers whose projects require iOS 13 or later have the option of using Apple's built-in layout system without introducing an external dependency.

The repository has no GitHub releases. Version information is tracked through CocoaPods metadata and Carthage.

## MagazineLayout Versus UICollectionViewCompositionalLayout

UICollectionViewCompositionalLayout is Apple's built-in layout system for UICollectionView, available since iOS 13. Like MagazineLayout, it supports multi-column grids, supplementary views, and section-level configuration. Its design centers on composing groups, items, and sections through value types rather than delegate callbacks.

The practical difference is the deployment target. MagazineLayout targets iOS 10, making it available for apps that need to run on older devices. UICollectionViewCompositionalLayout requires iOS 13. For apps already targeting iOS 13 and later, the built-in layout removes the need for an external dependency and the subclassing requirement.

MagazineLayout is licensed under Apache 2.0, which is permissive and compatible with both open-source and commercial applications. The repository does not document upgrade paths between versions, so testing layout behavior after a version update is the responsibility of the adopting project.

## Conclusion

MagazineLayout is a good fit for iOS engineers who need per-section column configurations and self-sizing cells without writing a custom layout from scratch, and who are targeting iOS 10 and later. Engineers building on iOS 13 and later should evaluate whether UICollectionViewCompositionalLayout, Apple's built-in option, covers their needs before taking on the subclassing requirement that MagazineLayout imposes. Check that your cells and reusable views can inherit from the provided base types, since projects with deep existing cell hierarchies may face friction. The last push was on 2026-09-24.

## FAQ

### What is the minimum iOS version MagazineLayout requires?

The README states MagazineLayout requires a deployment target of iOS 10.0 or later, and tvOS 10.0 or later. It also requires Swift 4 or later and Xcode 10 or later.

### Why does MagazineLayout require subclassing MagazineLayoutCollectionViewCell?

The README cites shortcomings in UIKit as the reason. The subclass overrides `preferredLayoutAttributesFitting(_:)` to let cells self-size correctly within MagazineLayout's measurement pass. As an alternative, the README describes copying that method's implementation into your own cell types without subclassing.

### How does MagazineLayout differ from UICollectionViewFlowLayout?

UICollectionViewFlowLayout uses fixed or uniformly estimated item sizes and does not support fractional-width columns, per-section sticky headers, or section backgrounds. MagazineLayout adds all of these through a delegate protocol and its own UICollectionViewLayout subclass.

## Sources

- [airbnb/MagazineLayout on GitHub](https://github.com/airbnb/MagazineLayout)
- [Issues](https://github.com/airbnb/MagazineLayout/issues)
- [License: Apache-2.0](https://github.com/airbnb/MagazineLayout/blob/master/LICENSE)
- [README](https://github.com/airbnb/MagazineLayout/blob/master/README.md)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/airbnb-magazinelayout
