SnapLayout alternatives and similar libraries
Based on the "Layout" category.
Alternatively, view SnapLayout alternatives based on common mentions on social networks and blogs.
Masonry9.9 0.0 L4 SnapLayout VS MasonryHarness the power of AutoLayout NSLayoutConstraints with a simplified, chainable and expressive syntax. Supports iOS and OSX Auto Layout
SnapKit9.9 2.5 L3 SnapLayout VS SnapKitA Swift Autolayout DSL for iOS & OS X
FDTemplateLayoutCell9.8 0.0 L4 SnapLayout VS FDTemplateLayoutCellTemplate auto layout cell for automatically UITableViewCell height calculating
PureLayout9.7 0.0 L4 SnapLayout VS PureLayoutThe ultimate API for iOS & OS X Auto Layout — impressively simple, immensely powerful. Objective-C and Swift compatible.
Cartography9.6 1.0 L5 SnapLayout VS CartographyA declarative Auto Layout DSL for Swift :iphone::triangular_ruler:
MyLinearLayout9.4 0.8 L3 SnapLayout VS MyLinearLayoutMyLayout 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
Neon9.3 0.0 L2 SnapLayout VS NeonA powerful Swift programmatic UI layout framework.
DeviceKit9.2 4.2 L3 SnapLayout VS DeviceKitDeviceKit is a value-type replacement of UIDevice.
SwiftBond9.2 0.0 L1 SnapLayout VS SwiftBondA Swift binding framework
LayoutKit9.0 1.1 L5 SnapLayout VS LayoutKitLayoutKit is a fast view layout library for iOS, macOS, and tvOS.
TinyConstraints9.0 0.0 L4 SnapLayout VS TinyConstraintsNothing but sugar.
Stevia8.9 0.0 L2 SnapLayout VS Stevia:leaves: Concise Autolayout code
Layout8.3 0.0 SnapLayout VS LayoutA declarative UI framework for iOS
PinLayout8.3 0.0 SnapLayout VS PinLayoutFast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]
EasyPeasy8.1 0.0 L4 SnapLayout VS EasyPeasyAuto Layout made easy
FlexLayout8.1 3.1 SnapLayout VS FlexLayoutFlexLayout adds a nice Swift interface to the highly optimized facebook/yoga flexbox implementation. Concise, intuitive & chainable syntax.
Device7.9 0.0 L3 SnapLayout VS DeviceLight weight tool for detecting the current device and screen size written in swift.
FLKAutoLayout7.8 0.0 L5 SnapLayout VS FLKAutoLayoutUIView category which makes it easy to create layout constraints in code
Grid7.4 0.0 SnapLayout VS GridThe most powerful Grid container missed in SwiftUI
set-simulator-locationCLI for setting location in the iOS simulator
SwiftBox6.5 0.0 L5 SnapLayout VS SwiftBoxFlexbox in Swift, using Facebook's css-layout.
Façade6.2 0.0 L5 SnapLayout VS FaçadeProgrammatic view layout for the rest of us.
Compose6.1 0.0 L5 SnapLayout VS ComposeCompose is a library that helps you compose complex and dynamic views.
SwiftAutoLayout6.0 0.0 L5 SnapLayout VS SwiftAutoLayoutTiny Swift DSL for Autolayout
Anchorage5.9 0.0 L5 SnapLayout VS AnchorageA collection of operators and utilities that simplify iOS layout code.
BrickKit5.9 0.0 L3 SnapLayout VS BrickKitDEPRECATED - BrickKit For IOS
MarkupKit5.5 7.6 L2 SnapLayout VS MarkupKitDeclarative UI for iOS applications
Relayout5.4 0.0 L5 SnapLayout VS RelayoutSwift microframework for declaring Auto Layout constraints functionally
EasyAnchor5.0 0.0 SnapLayout VS EasyAnchor⚓️ Declarative, extensible, powerful Auto Layout
UIDeviceComplete4.9 5.0 SnapLayout VS UIDeviceCompleteUIDevice extensions that fill in the missing pieces.
Layoutless4.9 0.0 SnapLayout VS LayoutlessWrite less UI code
Luminous4.6 2.1 L4 SnapLayout VS LuminousLuminous provides you a lot of information about the system and a lot of handy methods to quickly get useful data on the iOS platform.
Yalta4.5 0.0 SnapLayout VS YaltaIntuitive and powerful Auto Layout library
FlexboxLayout4.4 0.0 L4 SnapLayout VS FlexboxLayoutPort of Facebook's css-layout to Swift
MisterFusion4.4 0.0 L5 SnapLayout VS MisterFusionMisterFusion 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.
Cupcake4.4 0.0 SnapLayout VS CupcakeAn easy way to create and layout UI components for iOS (Swift version).
AnchorsDeclarative, extensible, powerful Auto Layout for iOS 8+ and macOS 10.10+
ManualLayout4.1 0.0 L5 SnapLayout VS ManualLayout✂ Easy to use and flexible library for manually laying out views and layers for iOS and tvOS. Supports AsyncDisplayKit.
QuickLayout4.0 1.3 SnapLayout VS QuickLayoutWritten in pure Swift, QuickLayout offers a simple and easy way to manage Auto Layout in code.
TapticEngine3.9 0.0 SnapLayout VS TapticEngineTapticEngine generates haptic feedback vibrations on iOS device.
WatchShaker3.6 0.0 L5 SnapLayout VS WatchShakerSimple motion detector for ⌚️ (watchOS) shake gesture.
MondrianLayout3.1 0.0 SnapLayout VS MondrianLayout🏗 A way to build AutoLayout rapidly than using InterfaceBuilder(XIB, Storyboard) in iOS.
Swiftstraints2.9 0.0 L5 SnapLayout VS SwiftstraintsAuto Layout In Swift Made Easy
BBLocationManager2.9 0.0 SnapLayout VS BBLocationManagerA Location Manager for easily implementing location services & geofencing in iOS. Ready for iOS 11.
Framezilla2.8 0.0 L4 SnapLayout VS FramezillaElegant library that wraps working with frames with a nice chaining syntax.
Restraint2.4 0.0 L5 SnapLayout VS RestraintMinimal Auto Layout in Swift
Anchorman2.2 0.0 L5 SnapLayout VS AnchormanAn autolayout library for the damn fine citizens of San Diego.
Bamboo2.1 0.0 SnapLayout VS BambooAuto Layout (and manual layout) in one line.
Manuscript2.0 0.0 L4 SnapLayout VS ManuscriptAutoLayoutKit in pure Swift.
Auto Layout Magic2.0 0.0 L3 SnapLayout VS Auto Layout MagicBuild 1 scene, let AutoLayoutMagic generate the constraints for you!
Appwrite - The Open Source Firebase alternative introduces iOS support
* 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 SnapLayout or a related project?
Concise API for Auto Layout. SnapLayout extends
NSView to deliver a list of APIs to improve readability while also shortening constraint code. Internally uses AutoLayout to provide the best experience. With SnapLayout, developers can remove boilerplate code but not at the cost of readability.
Imagine applying any or all of the following constraints in one line of code to a view: top, leading, trailing, bottom, width, height, centerX, centerY. Not enough? Start chaining your snap calls to support adjacents snaps. This is all possible with
Why Use It?
Lets use a real world example. Lets say the following view needs to be added. It has a centerX, centerY, width, and height constraint.
squareView.translatesAutoresizingMaskIntoConstraints = false squareView.widthAnchor.constraint(equalToConstant: 50) squareView.heightAnchor.constraint(equalToConstant: 50) squareView.centerXAnchor.constraint(equalTo: squareSuperview.centerXAnchor, constant: 0) squareView.centerYAnchor.constraint(equalTo: squareSuperview.centerYAnchor, constant: 0)
squareView.snap(width: 50, height: 50, centerX: 0, centerY: 0)
translatesAutoresizingMaskIntoConstraints and references the superview of
squareView when applying constraints. Built to be flexible, yet readable.
- Language Support: Swift (5.0)
- Fully Compatible With: Xcode 10.0 and higher
- Fully Compatible With: iOS 9.0 and above
- Fully Compatible With: macOS 10.11 and above
- Fully Compatible With: tvOS 9.0 and above
Installation with CocoaPods
Installation with Carthage
- All methods are prefixed with
snapfor quick Xcode autocomplete.
- Directly uses NSLayoutAnchor under the hood so the API is developer friendly
- Any view using
SnapLayoutwill not only have its
false, but also have its constraint activated.
- Snap offers many default parameters including the
viewargument. If a view parameter is not supplied, it is assumed your view will be snapping to its superview.
- Powerful API supporting snapping of adjacent views
func snap(to view: View? = nil, top: CGFloat? = nil, leading: CGFloat? = nil, bottom: CGFloat? = nil, trailing: CGFloat? = nil, width: CGFloat? = nil, height: CGFloat? = nil, centerX: CGFloat? = nil, centerY: CGFloat? = nil, priority: LayoutPriority = LayoutPriorityRequired, isActive: Bool = true) -> SnapManager func snap(to view: View? = nil, config: SnapConfig, priority: LayoutPriority = LayoutPriorityRequired, isActive: Bool = true) -> SnapManager func snapWidth(to view: View, multiplier: CGFloat = 1, priority: LayoutPriority = LayoutPriorityRequired, isActive: Bool = true) -> SnapManager func snapHeight(to view: View, multiplier: CGFloat = 1, priority: LayoutPriority = LayoutPriorityRequired, isActive: Bool = true) -> SnapManager func snap(size: CGSize, priority: LayoutPriority = LayoutPriorityRequired, isActive: Bool = true) -> SnapManager func snap(trailingView: View, constant: CGFloat = 0, priority: LayoutPriority = LayoutPriorityRequired, isActive: Bool = true) -> SnapManager func snap(leadingView: View, constant: CGFloat = 0, priority: LayoutPriority = LayoutPriorityRequired, isActive: Bool = true) -> SnapManager func snap(bottomView: View, constant: CGFloat = 0, priority: LayoutPriority = LayoutPriorityRequired, isActive: Bool = true) -> SnapManager func snap(topView: View, constant: CGFloat = 0, priority: LayoutPriority = LayoutPriorityRequired, isActive: Bool = true) -> SnapManager
let buttonSnapManager = button.snap(top: 50, leading: 50, trailing: 50, width: 30) buttonSnapManager.top?.constant = 100
Not only has this button applied 4 constraints to its superview, but each individual constraint is accessible through the returned
SnapManager type. The beauty of SnapLayout is not only its powerful API interface, but how easy it is to adjust constraints. Other API's simply return an array, but not SnapLayout. Each constraint is neatly packaged into a
Snapping Adjacent Views
button1.snap(trailingView: button2, constant: 8)
These buttons are now side by side where button2 is now the trailingView. No longer will developers have to think which trailing constraint should apply to which leading constraint. This keeps the code lean and clean.
let snapManager = view.snap(top: 8, leading: 8, width: 50) .snapHeight(to: superview, multiplier: 0.5) print(snapManager.top?.constant) # 8.0 print(snapManager.height?.constant) # 0.5
Snap calls may also be chained and will continue to return a
SnapConfig struct is also available where a developer may list all of their constraint constants beforehand and provide this type to the snap method argument.
let config = SnapConfig(top: 50, leading: 50, trailing: 50, width: 30, centerX: 0) button.snap(config: config)
SnapLayout assumes required priority (same default as Apple) unless otherwise specified for those created constraints.
button1.snap(trailingView: button2, constant: 8, priority: .low)
In the following example, the top, leading, bottom, and trailing constraint all have a priority of required; however, the height constraint has a
UILayoutPriority.defaultHigh priority. That's it!
rectangleView.snap(top: 48, leading: 16, bottom: 16, trailing: 16) .snap(height: 40, priority: .defaultHigh)
To Activate or not to Activate
SnapLayout, by default, activates all constraints it creates; however, this can be disabled by passing false to
button1.snap(trailingView: button2, constant: 8, isActive: false)
SnapLayout will also print out errors to log if a
snap was not properly applied.
SnapLayout Error - No constraint was applied for view: <UIView: 0x7fcb8f4031d0; frame = (0 0; 0 0); layer = <CALayer: 0x608000036320>>
Safe Area Layout Guide Support
SnapLayout will apply constraints using
safeAreaLayoutGuide if the app is running iOS 11; otherwise, it will apply the view's layout anchors directly.
To run the example project, run
pod try SnapLayout.
This example project contains not only an
Example-iOS target, but also an
Example-MacOS target. This is a great introduction to become more familiar with the library.
Satinder Singh, [email protected]
SnapLayout is available under the MIT license. See the LICENSE file for more info.
*Note that all licence references and agreements mentioned in the SnapLayout README section above are relevant to that project's source code only.