Swiftpack.co -  dankinsoid/VDLayout as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Declarative wrapper on UIKit
.package(url: "https://github.com/dankinsoid/VDLayout.git", from: "2.28.0")


CI Status Version License Platform


This repository provides a declarative way to layout in SwiftUI-style


view.add {
	UIStackView.V {
	.edges().equal(to: 0)
	.width.equal(to: { $0.height / 2 })



  • SubviewProtocol - protocol describes any type that can be used as a subview
  • SubviewsBuilder - function builder to create [SubviewProtocol], it allows use SwiftUI Views as well (also you can use any SubviewProtocol in SwiftUI ViewBuilder)
  • LtView, LtViewController - helper classes with createLayout() function to override, optional for use
  • UIKiView, UIKitViewController - SwiftUI wrappers on UIView and UIViewController: useful for PreviewProvider
  • .chain - property to create KeyPath chaining for views, after .chain you can write any property of view, then subscript with value ([value]) or Publisher to subscribe ([cb: somePublisher])
  • do {...} - function to any custom actions on view
  • add {...} - analog of addSubview but with SubviewsBuilder
  • with {...} - same as add but returns the view itself, for using in layout


For constraints this repo use ConstraintsOperators dependency, examples:

	.edges().equal(to: 0)
	.top.equal(to: view2.bottom + 4)
	.bottom.greater(than: view3.bottom + 10)
	.width.equal(to: { $0.superview?.height * 2 + 10 })

You can use subscripts instead of equal(to:...) to shorten: button.size[44]

Tables and collection

For tables and collections this repo use Carbon dependency UIList and UICollection - helper UITableView and UICollectionView subclasses

UIList($elements) {


  1. CocoaPods

Add the following line to your Podfile:

pod 'VDLayout'

and run pod update from the podfile directory first.

  1. Swift Package Manager

Create a Package.swift file.

// swift-tools-version:5.0
import PackageDescription

let package = Package(
  name: "SomeProject",
  dependencies: [
    .package(url: "https://github.com/dankinsoid/VDLayout.git", from: "2.11.0")
  targets: [
    .target(name: "SomeProject", dependencies: ["VDLayout"])
$ swift build


dankinsoid, voidilov@gmail.com


VDLayout is available under the MIT license. See the LICENSE file for more info.


Stars: 1
Last commit: Yesterday

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API