SugarAnchor alternatives and similar libraries
Based on the "Layout" category.
Alternatively, view SugarAnchor 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 -
FDTemplateLayoutCell
Template auto layout cell for automatically UITableViewCell height calculating -
PureLayout
The ultimate API for iOS & OS X Auto Layout — impressively simple, immensely powerful. Objective-C and Swift compatible. -
Cartography
A declarative Auto Layout DSL for Swift :iphone::triangular_ruler: -
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 -
LayoutKit
LayoutKit is a fast view layout library for iOS, macOS, and tvOS. -
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. -
Device
Light weight tool for detecting the current device and screen size written in swift. -
FLKAutoLayout
UIView category which makes it easy to create layout constraints in code -
set-simulator-location
CLI for setting location in the iOS simulator -
Compose
Compose is a library that helps you compose complex and dynamic views. -
Anchorage
A collection of operators and utilities that simplify iOS layout code. -
Relayout
Swift microframework for declaring Auto Layout constraints functionally -
UIDeviceComplete
UIDevice extensions that fill in the missing pieces. -
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. -
Cupcake
An easy way to create and layout UI components for iOS (Swift version). -
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. -
Anchors
Declarative, extensible, powerful Auto Layout for iOS 8+ and macOS 10.10+ -
QuickLayout
Written in pure Swift, QuickLayout offers a simple and easy way to manage Auto Layout in code. -
ManualLayout
✂ Easy to use and flexible library for manually laying out views and layers for iOS and tvOS. Supports AsyncDisplayKit. -
TapticEngine
TapticEngine generates haptic feedback vibrations on iOS device. -
WatchShaker
Simple motion detector for ⌚️ (watchOS) shake gesture. -
MondrianLayout
🏗 A way to build AutoLayout rapidly than using InterfaceBuilder(XIB, Storyboard) in iOS. -
BBLocationManager
A Location Manager for easily implementing location services & geofencing in iOS. Ready for iOS 11. -
Framezilla
Elegant library that wraps working with frames with a nice chaining syntax. -
Anchorman
An autolayout library for the damn fine citizens of San Diego. -
Auto Layout Magic
Build 1 scene, let AutoLayoutMagic generate the constraints for you!
Appwrite - The open-source backend cloud platform
* 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 SugarAnchor or a related project?
README
[Banner](SugarAnchor-Banner.png)
SugarAnchor is syntactic sugar on NSLayoutAnchor
to help us write more compact, readable and easy layout code. It wraps up all of NSLayoutXAxisAnchor
, NSLayoutYAxisAnchor
and NSLayoutDimension
functionalities under some easy to use operators to reduce verbosity.
Features
- Simple, concise, native[1]. Almost zero learning curve
- Typesafe, similar to NSLayoutAnchor
- Unit tested
- Small codebase (less than 300 LOC)
[1] Same NSLayoutAnchor/NSLayoutConstraints, just syntactic sugar on it
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
- [x] Xcode 8.3 or above
- [x] Swift 3.1
- [x] iOS 9.0 or above
Installation
SugarAnchor is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "SugarAnchor"
Operator Summary
Let's looks at a simple NSLayoutAnchor code:
(redView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20)).isActive = true
With SugarAnchor, it become:
redView.leadingAnchor =*= view.leadingAnchor + 20
Think *
as Active constraint and ~
as Inactive constraint. Then with =*=
, you'll create an active constraint directly or with =~=
you may create an inactive constraint which you can activate later.
view1.leftAnchor =*= view2.leftAnchor + 10
// Or
let leftConstraint = (view1.leftAnchor =~= view2.leftAnchor + 10)
leftConstraint.isActive = true
In each case, you'll get the constraint to keep or just ignore. For example, for an active one:
self.heightConstraint = (v1.heightAnchor =*= 200)
// Later somewhere
self.heightConstraint.constant = 100
Operator list
Operator | Description | Example |
---|---|---|
=*= | Equal(Active) | ❖ v1.leadingAnchor =*= v2.leadingAnchor ❖ v1.leftAnchor =*= v2.leftAnchor + 20 ❖ v1.widthAnchor =*= v2.widthAnchor / 2 + 10 ❖ v1.heightAnchor =*= 200 |
<*= | LessThanOrEqual(Active) | ❖ v1.bottomAnchor <*= container.bottomAnchor - 8 |
>*= | GreaterThanOrEqual(Active) | ❖ v2.leadingAnchor >*= v1.trailingAnchor + 5 |
=~= | Equal(Inactive) | ❖ (v1.widthAnchor =~= 200).isActive = true |
<~= | LessThanOrEqual(Inactive) | ❖ (v1.bottomAnchor <~= container.bottomAnchor - 8).isActive = true |
>~= | GreaterThanOrEqual(Inactive) | ❖ (v2.leadingAnchor >~= v1.trailingAnchor + 5).isActive = true |
Author
ashikahmad, [email protected]
License
SugarAnchor is available under the MIT license. See the LICENSE file for more info.
*Note that all licence references and agreements mentioned in the SugarAnchor README section above
are relevant to that project's source code only.