LayoutKit
Nested Layouts
This project is no longer used by LinkedIn and is currently unmaintained.
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:
LayoutKit also provides benefits that make it as easy to use as Auto Layout:
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)
We have found LayoutKit to be a useful tool, but you should be aware of what it is not.
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.