FastLayout - A UIKit or AppKit package for fast UI design

Related tags

Utility FastLayout
Overview

FastLayout

FastLayout is a UIKit or AppKit package for fast UI design.

Layout Example

import FastLayout

// MARK: - Create and configure subviews
let label = UILabel()
let button = UIButton()
label.text = "Hello"
label.textAlignment = .center
button.setTitle("hello world", for: .normal)
button.setTitleColor(.link, for: .normal)

// MARK: - Arrange subview layout
self.view.beginArrangeSubviews()
self.view.arrangerAddSubview(label) {
    $0.leftRight == self.view.leftRight
    $0.top == self.view.safeArea.top
    $0.height == 30                                     // Constraint to 30
}
self.view.arrangerAddSubview(button) {
    $0.leftTop == self.view.left & (label.bottom + 10)  // left = superLeft, top = label.bottom (offset 10)
    $0.right == self.view.right
    $0.height == label.height * 2                       // height = label.height (multiplier 2)
}
self.view.endArrangeSubviews()

Example: Display MxN button matrix

self.view.beginArrangeSubviews()
        
var btns = [[UIButton]]()
let lineCount = 10
let columnCount = 10
for lineId in 0..<lineCount {
    var line = [UIButton]()
    for columnId in 0..<columnCount {
        let btn = UIButton()
        btn.backgroundColor = .cyan
        btn.setTitle("(\(lineId), \(columnId))", for: .normal)
        line.append(btn)
        self.view.arrangerAddSubview(btn) {
            if columnId == 0 {
                $0.left == self.view.left
            }
            if columnId == columnCount - 1 {
                $0.right == self.view.right
            }
            if lineId == 0 {
                $0.top == self.view.safeAreaLayoutGuide.topAnchor
            }
            if lineId == lineCount - 1 {
                $0.bottom == self.view.bottomAnchor
            }
            if columnId > 0 {
                $0.width == line[columnId - 1].width
                $0.left == line[columnId - 1].right + 1
            }
            if lineId > 0 {
                $0.height == btns[lineId - 1][columnId].height
                $0.top == btns[lineId - 1][columnId].bottom + 1
            }
        }
    }
    btns.append(line)
}

self.view.endArrangeSubviews()
You might also like...
This is a app developed in Swift, using Object Oriented Programing, UIKit user interface programmatically, API Request and Kingfisher to load remote images

iOS NOW ⭐ This is a app developed in Swift, using Object Oriented Programing, UIKit user interface programmatically, API Request and Kingfisher to loa

SwiftExtensionKit - SwiftExtensionKit is to contain generic extension helpers for UIKit and Foundation

RichAppz PureSwiftExtensionKit SwiftExtensionKit is to contain generic extension

Swift-HorizontalPickerView - Customizable horizontal picker view component written in Swift for UIKit/iOS

Horizontal Picker View Customizable horizontal picker view component written in

DGPreview - Make UIKit project enable preview feature of SwiftUI
DGPreview - Make UIKit project enable preview feature of SwiftUI

DGPreview Make UIKit project enable preview feature of SwiftUI Requirements iOS

A command-line tool and Swift Package for generating class diagrams powered by PlantUML
A command-line tool and Swift Package for generating class diagrams powered by PlantUML

SwiftPlantUML Generate UML class diagrams from swift code with this Command Line Interface (CLI) and Swift Package. Use one or more Swift files as inp

A Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and other native frameworks.
A Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and other native frameworks.

ZamzamKit ZamzamKit is a Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and othe

Updeto is a simple package that help update checker for iOS Apps

Updeto is a simple package that will help you to check if the currently installed version is the same as the latest one available on App Store.

Swift implementation of the package url spec

PackageURL Swift implementation of the package url specification. Requirements Swift 5.3+ Usage import PackageURL let purl: PackageURL = "pkg:swift/a

Mechanical editing support for Package.swift manifests

Mechanical editing support for Package.swift manifests. Implements Swift Evolution proposal SE-301

Owner
null
Swift Package Manager plugin which runs ActionBuilder to create a Github Actions workflow for a swift package.

ActionBuilderPlugin A Swift Package Manager command which builds a Github Actions workflow for the current package. By default the workflow file will

Elegant Chaos 4 Jul 20, 2022
🦀Amazingly incredible extraordinary lightning fast diffing in Swift

DeepDiff ❤️ Support my apps ❤️ Push Hero - pure Swift native macOS application to test push notifications PastePal - Pasteboard, note and shortcut man

Khoa 2k Dec 29, 2022
💻 A fast and flexible O(n) difference algorithm framework for Swift collection.

A fast and flexible O(n) difference algorithm framework for Swift collection. The algorithm is optimized based on the Paul Heckel's algorithm. Made wi

Ryo Aoyama 3.3k Jan 4, 2023
Safe and fast access to SwiftUI PreviewDevice

SafePreviewDevice Motivation At WWDC 2019, Apple announced SwiftUI a new library for building UI in a simple and fast way. Xcode’s SwiftUI preview let

Antonino Francesco Musolino 11 Jun 28, 2022
FluxCapacitor makes implementing Flux design pattern easily with protocols and typealias.

FluxCapacitor makes implementing Flux design pattern easily with protocols and typealias. Storable protocol Actionable protocol Dispatch

Taiki Suzuki 123 Aug 23, 2022
Swifty closures for UIKit and Foundation

Closures is an iOS Framework that adds closure handlers to many of the popular UIKit and Foundation classes. Although this framework is a substitute f

Vinnie Hesener 1.7k Dec 21, 2022
🟣 Verge is a very tunable state-management engine on iOS App (UIKit / SwiftUI) and built-in ORM.

Verge is giving the power of state-management in muukii/Brightroom v2 development! Verge.swift ?? An effective state management architecture for iOS -

VergeGroup 478 Dec 29, 2022
Pigeon is a SwiftUI and UIKit library that relies on Combine to deal with asynchronous data.

Pigeon ?? Introduction Pigeon is a SwiftUI and UIKit library that relies on Combine to deal with asynchronous data. It is heavily inspired by React Qu

Fernando Martín Ortiz 369 Dec 30, 2022
Customize and resize sheets in SwiftUI with SheeKit. Utilise the power of `UISheetPresentationController` and other UIKit features.

SheeKit Customize and resize sheets in SwiftUI with SheeKit. Utilise the power of UISheetPresentationController and other UIKit features. Overview She

Eugene Dudnyk 67 Dec 31, 2022