LayoutKit is a fast view layout library for iOS, macOS, and tvOS.
Clone or download
staguer Bumping version to 10.0.1 (#241)
Bugfix version fixes handling of flexibility on Overlay and Inset layouts.
OverlayLayout now has an optional flexibility parameter, and defaults to the flexibility of the first primary layout.
InsetLayout now has an optional flexibility parameter, and the corresponding builder’s flexibility parameter is now hooked up whereas it had no effect before.
Latest commit 187c7ae Oct 16, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
ExampleLayouts Fixing warnings that show up in Xcode 10. (#234) Oct 3, 2018
LayoutKit.playground Fixing animation on Counter playground. (#236) Oct 5, 2018
LayoutKit.xcodeproj Adding IDEWorkspaceChecks.plist (#237) Oct 5, 2018
LayoutKitObjCSampleApp Making LOKLayout configureView method non-optional (#225) Aug 2, 2018
LayoutKitSampleApp Add support for multiple primary layouts in OverlayLayout (#217) Aug 31, 2018
LayoutKitTests Reset reused views' transform and layer anchor point (#231) Oct 4, 2018
Sources Bumping version to 10.0.1 (#241) Oct 16, 2018
Tests Migrate swift version 4.0 to 4.1 (#223) Aug 2, 2018
docs Fix doc link for ButtonLayout (#199) May 2, 2018
.gitignore Update .gitignore Add .DS_Store for macOS Dec 2, 2016
.swift-version Migrate swift version 4.0 to 4.1 (#223) Aug 2, 2018
.travis.yml Migrate swift version 4.0 to 4.1 (#223) Aug 2, 2018 Update Jul 27, 2016
LICENSE Open source LayoutKit Jun 22, 2016
LayoutKit-iOS copy-Info.plist Adding builders to the pod. Creating target for objc code. (#194) Mar 13, 2018
LayoutKit.podspec Bumping version to 10.0.1 (#241) Oct 16, 2018
LayoutKitObjC.podspec Bumping version to 10.0.1 (#241) Oct 16, 2018
NOTICE Open source LayoutKit Jun 22, 2016
Package.swift create sample app to test cocoapods integration (#125) Apr 17, 2017 remove "docs: null%" (#174) Dec 8, 2017 Version number bump 7.0.0 to 7.0.1 and update (#188) Feb 27, 2018 Migrate swift version 4.0 to 4.1 (#223) Aug 2, 2018 Support macOS (#11) Jul 13, 2016
mkdocs.yml 2.0.0 pod spec and documentation updates Aug 22, 2016


CocoaPods GitHub release Build Status codecov

LayoutKit is a fast view layout library for iOS, macOS, and tvOS.


LinkedIn created LayoutKit because we have found that Auto Layout is not performant enough for complicated view hierarchies in scrollable views. For more background, read the blog post.


LayoutKit has many benefits over using Auto Layout:

  • Fast: LayoutKit is as fast as manual layout code and is significantly faster than Auto Layout.
  • Asynchronous: Layouts can be computed in a background thread so user interactions are not interrupted.
  • Declarative: Layouts are declared with immutable data structures. This makes layout code easier to develop, document, code review, test, debug, profile, and maintain.
  • Cacheable: Layout results are immutable data structures so they can be precomputed in the background and cached to increase user perceived performance.

LayoutKit also provides benefits that make it as easy to use as Auto Layout:

  • UIKit friendly: LayoutKit produces UIViews and also provides an adapter that makes it easy to use with UITableView and UICollectionView.
  • Internationalization: LayoutKit automatically adjusts view frames for right-to-left languages.
  • Swift: LayoutKit can be used in Swift applications and playgrounds.
  • Tested and production ready: LayoutKit is covered by unit tests and is being used inside of recent versions of the LinkedIn and LinkedIn Job Search iOS apps.
  • Open-source: Not a black box like Auto Layout.
  • Apache License (v2): Your lawyers will be happy that there are no patent shenanigans.

Hello world

let image = SizeLayout<UIImageView>(width: 50, height: 50, config: { imageView in
    imageView.image = UIImage(named: "earth.jpg")

let label = LabelLayout(text: "Hello World!", alignment: .center)

let stack = StackLayout(
    axis: .horizontal,
    spacing: 4,
    sublayouts: [image, label])

let insets = UIEdgeInsets(top: 4, left: 4, bottom: 4, right: 8)
let helloWorld = InsetLayout(insets: insets, sublayout: stack)
helloWorld.arrangement().makeViews(in: rootView)

Hello world example layout


We have found LayoutKit to be a useful tool, but you should be aware of what it is not.

  • LayoutKit is not a constraint based layout system. If you wish to express a constraint between views, then those views need to be children of a single layout that implements code to enforce that constraint.
  • LayoutKit is not flexbox, but you may find similarities.


LayoutKit can be installed with CocoaPods or Carthage.


Add this to your Podspec:

pod 'LayoutKit'

Then run pod install.


Add this to your Cartfile:

github "linkedin/LayoutKit"

Then run carthage update.


Now you are ready to start building UI.