FrameLayoutKit is a super fast and easy to use autolayout kit

Overview

FrameLayoutKit

Platform Language Version SwiftPM Compatible License

image

FrameLayout is a super fast and easy to use layout library for iOS and tvOS.

For Objective-C version: NKFrameLayoutKit (Deprecated, not recommended)

Why?

Say NO to autolayout constraint nightmare:

NO YES

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

FrameLayoutKit is available through Swift Package Manager (Recommended) and CocoaPods:

Regardless, make sure to import the project wherever you may use it:

import FrameLayoutKit

Cocoapods:

FrameLayoutKit can be installed as a CocoaPod. To install, include this in your Podfile.

pod "FrameLayoutKit"

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into Xcode and the Swift compiler. This is the recommended installation method. Updates to FrameLayoutKit will always be available immediately to projects with SPM. SPM is also integrated directly with Xcode.

If you are using Xcode 11 or later:

  1. Click File
  2. Swift Packages
  3. Add Package Dependency...
  4. Specify the git URL for FrameLayoutKit.
https://github.com/kennic/FrameLayoutKit.git

Example

This is how FrameLayoutKit layout the card view below:

let frameLayout = HStackLayout {
  $0.add(VStackLayout {
    $0.add(earthImageView).alignment = (.top, .center)
    $0.addSpace().flexible()
    $0.add(rocketImageView).alignment = (.center, .center)
  })
		
  $0.add(VStackLayout {
    $0.add([nameLabel, dateLabel])
    $0.addSpace(10)
    $0.add(messageLabel)
    $0.spacing = 5.0
  })

  $0.spacing = 15.0
  $0.padding(top: 15, left: 15, bottom: 15, right: 15)
  $0.debug = true
}

Hello World

Or you can use operand syntax for shorter/cleaner code:

let frameLayout = StackFrameLayout(axis: .horizontal)
frameLayout + VStackLayout {
	($0 + earthImageView).alignment = (.top, .center)
	($0 + 0).flexible() // add a flexible space
	($0 + rocketImageView).alignment = (.center, .center)
}
frameLayout + VStackLayout {
	$0 + [nameLabel, dateLabel] // add an array of views
	$0 + 10 // add space with 10 px fixed
	$0 + messageLabel // add a single view
	$0.spacing = 5.0 // spacing between views
}

frameLayout.spacing = 15.0
frameLayout.padding(top: 15, left: 15, bottom: 15, right: 15)
frameLayout.debug = true // show debug frame
}

Benchmark

FrameLayoutKit is one of the fastest layout libraries. Benchmark Results

See: Layout libraries benchmark's project

Todo

  • Swift Package Manager
  • CocoaPods support
  • Objective-C version (Deprecated - Not recommended)
  • Swift version
  • Examples
  • Documents

Author

Nam Kennic, [email protected]

License

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

You might also like...
A Swift Autolayout DSL for iOS & OS X
A Swift Autolayout DSL for iOS & OS X

SnapKit is a DSL to make Auto Layout easy on both iOS and OS X. ⚠️ To use with Swift 4.x please ensure you are using = 4.0.0 ⚠️ ⚠️ To use with Swift

🏗 MondrianLayout - describing structured layout for AutoLayout
🏗 MondrianLayout - describing structured layout for AutoLayout

🏗 A DSL based layout builder for AutoLayout

This
This "Calculator" application is a simple one screen design of calculator screen i have made this single screen design application just to practice AutoLayout concepts.

Calculator Layout This "Calculator" application is a simple one screen design of calculator screen i have made this single screen design application j

A bit of steroids for AutoLayout, powered by Swift.

AutoLayoutPlus AutoLayoutPlus is a Swift library consisting in a set of extensions to help dealing with Auto Layout programatically. With AutoLayoutPl

Tiny Swift DSL for Autolayout

SwiftAutoLayout SwiftAutoLayout is a tiny DSL for Autolayout intended to provide a more declarative way to express layout constraints. Here's a quick

An autolayout library for the damn fine citizens of San Diego.
An autolayout library for the damn fine citizens of San Diego.

Anchorman Do you think autolayout has to be hard? Nah. NSLayoutAnchor is pretty neat! But it's still a bit tedious of an API. Try writing .translatesA

Minimal AutoLayout convenience layer. Program constraints succinctly.

MiniLayout Minimal AutoLayout convenience layer. Program constraints succinctly. Usage Put label over textField // using MiniLayout: view.constrain(la

A AutoLayout Utility for iOS

QLayout is an Utility to make Auto Layout easy on iOS. Contents Requirements Installation Usage Credits License Requirements iOS 8.0+ Swift 3.0+ Insta

AutoLayout Micro DSL SPM from Chris Eidhof's article

EasyAutoLayout Intro EasyAutoLayout is a small framework built using the ideas presented in the article called Autolayout Micro DSL by Chris Eidhof. I

Releases(5.2.6)
Owner
Nam Kennic
Nam Kennic
The fast path to autolayout views in code

NorthLayout The fast path to autolayout views in code Talks https://speakerdeck.com/banjun/auto-layout-with-an-extended-visual-format-language at AltC

banjun 36 Jul 15, 2022
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

Extremely Fast views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainabl

layoutBox 2.1k Dec 22, 2022
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast

Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

layoutBox 2.1k Jan 2, 2023
An extension that simplifies the work with Swift AutoLayout by writing cleaner, more natural and easy-reading code.

Installation For now you're able to clone repo in your project or download ZIP folder manually. git clone https://github.com/votehserxam/AutoLayout.gi

Max 3 Nov 8, 2022
MisterFusion is Swift DSL for AutoLayout. It is the extremely clear, but concise syntax, in addition, can be used in both Swift and Objective-C. Support Safe Area and Size Class.

MisterFusion MisterFusion makes more easier to use AutoLayout in Swift & Objective-C code. Features Simple And Concise Syntax Use in Swift and Objecti

Taiki Suzuki 316 Nov 17, 2022
Harness the power of AutoLayout NSLayoutConstraints with a simplified, chainable and expressive syntax. Supports iOS and OSX Auto Layout

Masonry Masonry is still actively maintained, we are committed to fixing bugs and merging good quality PRs from the wider community. However if you're

null 18k Jan 5, 2023
An easier and faster way to code Autolayout

EZAnchor 中文介绍 An easier way to code Autolayout Are you annoyed of coding .active = true while using Autolayout Anchors over and over again? Are you an

Alex.Liu 25 Feb 20, 2022
SwiftLayout - View hierarchy and autolayout DSL library

SwiftLayout view hierarchy and autolayout DSL library goal 뷰의 계층구조와 constraint 관

iOS Swifty Krew 104 Dec 28, 2022
Write concise Autolayout code

Winner of Hacking with Swift Recommended award You + Stevia = ?? ?? Write concise, readable layouts ?? Reduce your maintenance time ?? Compose your st

Fresh 3.3k Jan 6, 2023
📱AutoLayout can be set differently for each device

DeviceLayout DeviceLayout is a Swift framework that lets you set Auto Layout constraints's differently for each device Using only IBInspector of Xcode

Cruz 171 Oct 11, 2022