NorthLayout
The fast path to autolayout views in code
Talks
https://speakerdeck.com/banjun/auto-layout-with-an-extended-visual-format-language at AltConf19
https://speakerdeck.com/banjun/lets-start-vfl
Simple Usage
See also Example
project.
View Level Safe Area Example
See also Example
project.
Advanced Example
See Example
project.
Features
? No Storyboards Required
Let's autolayout in code. boilerplates such as translatesAutoresizingMaskIntoConstraints = false
and adding as subview are coded in northLayoutFormat()
.
↔️ Visual Format Language
Use Visual Format Language (VFL) for layout.
Auto Layout Guide: Visual Format Language
⏸ Extended Visual Format for Layout Margins & Safe Area
In addition to Apple VFL above, NorthLayout introduces ||
syntax for layout margin bounds.
? View Controller level & View level layout
In autolayout, there is some differences in view of view controller and independent view. northLayoutFormat
is available for view controller and view.
You can use |
as topLayoutGuide or bottomLayoutGuide (mainly for before iOS 11) and avoid conflicting scroll adjustments on view controllers.
You can also code layout simply without a view controller on views.
?? iOS & macOS
Available for UIView & NSView
Migration to NorthLayout 5
NorthLayout 4 has supported Safe Area by translating |
bounds as safe area layout guides by default.
NorthLayout 5 adds breaking changes that introduces ||
layout margin guides and thus |
no longer respects Safe Area.
Choose |
to stick to edges, or ||
to inset in layout margins or safe area.
Installation
NorthLayout is available through CocoaPods. To install
it, simply add the following line to your Podfile:
Code Snippets
Code snippets help writing VFL activated in string literal scope.
The Name
NorthLayout is named after where it was cocoapodized, Lake Toya in the North prefecture of Japan, the setting of Celestial Method.
License
NorthLayout is available under the MIT license. See the LICENSE file for more info.