All Projects → wlgemini → Driftwood

wlgemini / Driftwood

Licence: MIT license
Driftwood is a DSL to make Auto Layout easy on iOS, tvOS and macOS.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Driftwood

Uicollectionview Layouts Kit
📐 A set of custom layouts for UICollectionView with examples [Swift 5.3, iOS 12].
Stars: ✭ 410 (+2828.57%)
Mutual labels:  uikit, constraints, autolayout
Invalidating
Backports the new @invalidating property wrapper to older platforms
Stars: ✭ 53 (+278.57%)
Mutual labels:  tvos, uikit, appkit
Swiftautolayout
Write constraints in a concise, expressive, Swifty way.
Stars: ✭ 83 (+492.86%)
Mutual labels:  uikit, constraints, autolayout
WebPKit
A framework that extends a variety of Cocoa APIs with capabilities for encoding and decoding WebP files for all of Apple's platforms.
Stars: ✭ 29 (+107.14%)
Mutual labels:  tvos, uikit, appkit
Kvconstraintkit
An Impressive Auto Layout DSL for iOS, tvOS & OSX. & It is written in pure swift.
Stars: ✭ 91 (+550%)
Mutual labels:  tvos, constraints, autolayout
SPConfetti
Show the confetti only when the user is having fun, and if not having fun, don't show it.
Stars: ✭ 187 (+1235.71%)
Mutual labels:  tvos, uikit
Misterfusion
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.
Stars: ✭ 314 (+2142.86%)
Mutual labels:  tvos, autolayout
Layoutframeworkbenchmark
Benchmark the performances of various Swift layout frameworks (autolayout, UIStackView, PinLayout, LayoutKit, FlexLayout, Yoga, ...)
Stars: ✭ 316 (+2157.14%)
Mutual labels:  tvos, autolayout
Vtacknowledgementsviewcontroller
Acknowledgements screen displaying a list of licenses, for example from CocoaPods dependencies.
Stars: ✭ 863 (+6064.29%)
Mutual labels:  tvos, uikit
Kgnautolayout
Making AutoLayout Easy
Stars: ✭ 127 (+807.14%)
Mutual labels:  uikit, autolayout
Acknowlist
Acknowledgements screen displaying a list of licenses, for example from CocoaPods dependencies.
Stars: ✭ 392 (+2700%)
Mutual labels:  tvos, uikit
VanillaConstraints
🍦 Simplified and chainable AutoLayout constraints for iOS.
Stars: ✭ 42 (+200%)
Mutual labels:  constraints, autolayout
curry
curry is a framework built to enhance and compliment Foundation and UIKit.
Stars: ✭ 47 (+235.71%)
Mutual labels:  tvos, uikit
Drawer View
📤 Custom UI component for iOS, replication of Apple's Apple Music player and Shortcuts’ components view [Swift 5.0, iOS 12].
Stars: ✭ 136 (+871.43%)
Mutual labels:  uikit, autolayout
CompositionalLayoutDSL
CompositionalLayoutDSL, library to simplify the creation of UICollectionViewCompositionalLayout. It wraps the UIKit API and makes the code shorter and easier to read.
Stars: ✭ 47 (+235.71%)
Mutual labels:  tvos, appkit
Swiftui
A collaborative list of awesome SwiftUI resources. Feel free to contribute!
Stars: ✭ 774 (+5428.57%)
Mutual labels:  tvos, uikit
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+76371.43%)
Mutual labels:  tvos, uikit
StoryboardConstraint
A simple way to use programmatically Autolayout Constraint created in Storyboard.
Stars: ✭ 25 (+78.57%)
Mutual labels:  constraints, autolayout
Basecomponents
BaseComponents aims to provide easily reusable and understandable components to increase productivity with UIKit and Foundation APIs
Stars: ✭ 92 (+557.14%)
Mutual labels:  uikit, autolayout
SwiftCurrent
A library for managing complex workflows in Swift
Stars: ✭ 286 (+1942.86%)
Mutual labels:  tvos, uikit

Driftwood

Driftwood CI Version License Platform

English|中文

Driftwood is a DSL to make Auto Layout easy on iOS, tvOS and macOS.

Requirements

  • iOS 8.0+/macOS 10.11+/tvOS 9.0+
  • Swift 4.2+

Installation

Driftwood is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Driftwood'

Usage

Driftwood is easy to use, you can make full constraints satisfication in just a few code.

Let's say we want to layout a box that is constrained to it’s superview’s edges with 0pts of padding.

let box = UIView()
superview.addSubview(box)
box.dw.make().left(0).top(0).right(0).bottom(0)

Or another way:

let box = UIView()
superview.addSubview(box)
box.dw.make().edge(insets: .zero)

Attribute

All NSLayoutConstraint.Attribute cases are available in Driftwood.

Let's say view1 is at the bottom of view2, offset with 10pts.

view1.dw.make().top(10, to: view2.dw.bottom)

Full list of NSLayoutConstraint.Attribute:

Horizontal attribute property Horizontal attribute function NSLayoutConstraint.Attribute
dw.left dw.make().left() .left
dw.right dw.make().right() .right
dw.leading dw.make().leading() .leading
dw.trailing dw.make().trailing() .trailing
dw.centerX dw.make().centerX() .centerX
dw.leftMargin dw.make().leftMargin() .leftMargin
dw.rightMargin dw.make().rightMargin() .rightMargin
dw.leadingMargin dw.make().leadingMargin() .leadingMargin
dw.trailingMargin dw.make().trailingMargin() .trailingMargin
Vertical attribute property Vertical attribute function NSLayoutConstraint.Attribute
dw.top dw.make().top() .top
dw.bottom dw.make().bottom() .bottom
dw.centerY dw.make().centerY() .centerY
dw.lastBaseline dw.make().lastBaseline() .lastBaseline
dw.firstBaseline dw.make().firstBaseline() .firstBaseline
dw.topMargin dw.make().topMargin() .topMargin
dw.bottomMargin dw.make().bottomMargin() .bottomMargin
dw.centerYWithinMargins dw.make().centerYWithinMargins() .centerYWithinMargins
Size attribute property Size attribute function NSLayoutConstraint.Attribute
dw.width dw.make().width() .width
dw.height dw.make().height() .height

Relation & Multiply & Priority

  • relation: default is .equal
  • multiply: default is 1
  • priority: default is .required

dw.make()

As you see above, you can use dw.make() to make full constraints easily.

dw.update()

You can use dw.update() to updating constant and priority value of a constraint.

view1.dw.update().top(200)

view2.dw.update().left(100, priority: .required)

dw.remake()

dw.remake() is similar to dw.make(), but will first remove all existing constraints installed by Driftwood.

view.dw.remake().left(20).top(30).width(20).height(10)

dw.remove()

You can use dw.remove() to removing any existing constraints installed by Driftwood.

view.dw.remove().left().top()

dw.removeAll()

Sometimes, you may just want to remove all constraints installed before. You can use dw.removeAll() to removing all existing constraints installed by Driftwood.

view.dw.removeAll()

LayoutGuide

Driftwood can works with LayoutGuide easily.

let guide = UILayoutGuide()
superview.addLayoutGuide(guide)
guide.dw.make().left(10).top(10).height(10).width(10)

let box = UIView()
superview.addSubview(box)
box.dw.make().top(0, to: guide.dw.bottom).left(0).right(0).height(10)

Cache

All constraints installed by Driftwood will be cached for future reuse.

Debug

You can labeled with a name to any View or LayoutGuide for debug.

view.dw.make(labeled: "MyView").left(0).left(0)

It will be logs like this:

<Driftwood.@ViewController#23.[make left].(UIView`MyView`:0x00007fc636525da0)>: Duplicated constraint.

If resulting Unable to simultaneously satisfy constraints, it will be logs like this for each constraint installed by Driftwood:

<Driftwood.@ViewController#23.[make left].(UIView`MyView`:0x00007fc636525da0.left == UIView:0x00007fc636525111.right)>

NOTE: In release, Driftwood will not log debug info.

Demo

You can download this repo to see more usage.

Author

wlgemini, [email protected]

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].