SwiftAutoLayout alternatives and similar libraries
Based on the "Layout" category.
Alternatively, view SwiftAutoLayout alternatives based on common mentions on social networks and blogs.
-
Masonry
Harness the power of AutoLayout NSLayoutConstraints with a simplified, chainable and expressive syntax. Supports iOS and OSX Auto Layout -
PureLayout
The ultimate API for iOS & OS X Auto Layout — impressively simple, immensely powerful. Objective-C and Swift compatible. -
MyLinearLayout
MyLayout is a powerful iOS UI framework implemented by Objective-C. It integrates the functions with Android Layout,iOS AutoLayout,SizeClass, HTML CSS float and flexbox and bootstrap. So you can use LinearLayout,RelativeLayout,FrameLayout,TableLayout,FlowLayout,FloatLayout,PathLayout,GridLayout,LayoutSizeClass to build your App 自动布局 UIView UITableView UICollectionView RTL -
PinLayout
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] -
FlexLayout
FlexLayout adds a nice Swift interface to the highly optimized facebook/yoga flexbox implementation. Concise, intuitive & chainable syntax. -
Luminous
Luminous provides you a lot of information about the system and a lot of handy methods to quickly get useful data on the iOS platform. -
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. -
ManualLayout
✂ Easy to use and flexible library for manually laying out views and layers for iOS and tvOS. Supports AsyncDisplayKit. -
QuickLayout
Written in pure Swift, QuickLayout offers a simple and easy way to manage Auto Layout in code. -
MondrianLayout
🏗 A way to build AutoLayout rapidly than using InterfaceBuilder(XIB, Storyboard) in iOS. -
Framezilla
DISCONTINUED. Elegant library that wraps working with frames with a nice chaining syntax. -
BBLocationManager
A Location Manager for easily implementing location services & geofencing in iOS. Ready for iOS 11.
WorkOS - The modern identity platform for B2B SaaS
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of SwiftAutoLayout or a related project?
README
SwiftAutoLayout
SwiftAutoLayout is a tiny DSL for Autolayout intended to provide a more declarative way to express layout constraints. Here's a quick example:
// this:
let constraint = view1.left == view2.right * 2.0 + 10.0 ~ 750
// is equivalent to:
let constraint = NSLayoutConstraint(item: view1, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: view2, attribute: NSLayoutAttribute.Right, multiplier: 2.0, constant: 10.0)
constraint.priority = 750
You may notice that this looks a lot like the linear equation that a constraint represents. From the Apple documentation:
The relationship involves a first attribute, a relationship type, and a modified second value formed by multiplying an attribute by a constant factor and then adding another constant factor to it. In other words, constraints look very much like linear equations of the following form:
attribute1 == multiplier × attribute2 + constant
SwiftAutoLayout allows you to more effectively communicate the intent of a constraint by making the syntax more similar to the equation that it represents.
Installing
Use Swift Package Manager or add SwiftAutoLayout.xcodeproj
as a subproject and link against either SwiftAutoLayout-iOS.framework
or SwiftAutoLayout-Mac.framework
depending on the platform.
Attributes
Layout attributes are defined as properties added in extensions of UIView
and UILayoutGuide
on iOS and NSView
and NSLayoutGuide
on OS X. For example, UIView.width
and UIView.height
represent NSLayoutAttribute.Width
and NSLayoutAttribute.Height
, respectively.
Layout guides (conforming to UILayoutSupport
) in UIViewController
are also supported using the topLayoutGuideTop
, topLayoutGuideBottom
, bottomLayoutGuideTop
, and bottomLayoutGuideBottom
properties.
Relations
Relations are expressed using the overloaded operators ==
(NSLayoutRelation.Equal
), >=
(NSLayoutRelation.GreaterThanOrEqual
), and <=
(NSLayoutRelation.LessThanOrEqual
).
Examples
Activating Single Constraint
(view1.left == view2.right * 2.0 + 10.0 ~ 750).active = true
Activating Multiple Constraints
NSLayoutConstraint.activateConstraints([
view2.centerX == view2.superview!.centerX,
view2.centerY == view2.superview!.centerY,
view1.left == view2.right * 2.0 + 10.0 ~ 750,
view1.top == view2.bottom + 5.0,
view1.width >= 200,
view1.height >= 400,
view1.trailing == layoutGuide.trailing,
view2.leading == layoutGuide.leading
])
Contact
- Indragie Karunaratne
- @indragie
- http://indragie.com
License
SwiftAutoLayout is licensed under the MIT License.
*Note that all licence references and agreements mentioned in the SwiftAutoLayout README section above
are relevant to that project's source code only.