All Projects → alexliubj → EZAnchor

alexliubj / EZAnchor

Licence: MIT License
An easier and faster way to code Autolayout

Programming Languages

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

Projects that are alternatives of or similar to EZAnchor

Tinyconstraints
Nothing but sugar.
Stars: ✭ 3,721 (+14784%)
Mutual labels:  layout, constraints, constraint, sugar, nslayoutconstraint, superview, center
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 UITab…
Stars: ✭ 4,152 (+16508%)
Mutual labels:  layout, constraints, autolayout
Uicollectionview Layouts Kit
📐 A set of custom layouts for UICollectionView with examples [Swift 5.3, iOS 12].
Stars: ✭ 410 (+1540%)
Mutual labels:  layout, constraints, autolayout
Kvconstraintkit
An Impressive Auto Layout DSL for iOS, tvOS & OSX. & It is written in pure swift.
Stars: ✭ 91 (+264%)
Mutual labels:  layout, constraints, autolayout
wwlayout
Swifty DSL for programmatic Auto Layout in iOS
Stars: ✭ 46 (+84%)
Mutual labels:  layout, constraints, autolayout
VanillaConstraints
🍦 Simplified and chainable AutoLayout constraints for iOS.
Stars: ✭ 42 (+68%)
Mutual labels:  layout, constraints, autolayout
Stevia
🍃 Concise Autolayout code
Stars: ✭ 3,182 (+12628%)
Mutual labels:  layout, constraints, autolayout
Core Layout
Flexbox & CSS-style Layout in Swift.
Stars: ✭ 215 (+760%)
Mutual labels:  layout, constraints, autolayout
Snapkit
A Swift Autolayout DSL for iOS & OS X
Stars: ✭ 18,091 (+72264%)
Mutual labels:  layout, constraints, autolayout
Easyswiftlayout
Lightweight Swift framework for Apple's Auto-Layout
Stars: ✭ 345 (+1280%)
Mutual labels:  layout, constraints, autolayout
SuperPuperDuperLayout
Super puper duper mega easy awesome wrapper over auto layout!!111!!1!!!1!!!11111!!!1!!
Stars: ✭ 14 (-44%)
Mutual labels:  layout, constraints, sugar
Autoinch
优雅的iPhone全尺寸/等比例精准适配工具
Stars: ✭ 395 (+1480%)
Mutual labels:  layout, autolayout
Keyboardlayoutguide
⌨️ Manage iOS keyboard with Apple's missing KeyboardLayoutGuide
Stars: ✭ 1,054 (+4116%)
Mutual labels:  layout, autolayout
Framelayoutkit
FrameLayoutKit is a super fast and easy to use autolayout kit
Stars: ✭ 53 (+112%)
Mutual labels:  layout, autolayout
Nerdyui
An easy way to create and layout UI components for iOS.
Stars: ✭ 381 (+1424%)
Mutual labels:  layout, constraints
Flexlib
FlexLib是一个基于flexbox模型,使用xml文件进行界面布局的框架,融合了web快速布局的能力,让iOS界面开发像写网页一样简单快速
Stars: ✭ 1,569 (+6176%)
Mutual labels:  layout, autolayout
Snapkitextend
SnapKit的扩展,SnapKit类似于Masonry,但是其没有对Arry的设置和对等间距排列的布局等,此扩展是类似Masonry的写法对SnapKit的补充,同时补充九宫格布局方式
Stars: ✭ 110 (+340%)
Mutual labels:  layout, constraints
Easypeasy
Auto Layout made easy
Stars: ✭ 1,877 (+7408%)
Mutual labels:  layout, constraints
StoryboardConstraint
A simple way to use programmatically Autolayout Constraint created in Storyboard.
Stars: ✭ 25 (+0%)
Mutual labels:  constraints, autolayout
dynamic-motion
Provide additional functionality to Android MotionLayout.
Stars: ✭ 34 (+36%)
Mutual labels:  layout, constraint

EZAnchor 中文介绍

An easier way to code Autolayout

Image of EZAnchor

Language: Swift 4 Platform: iOS 9+ CocoaPods compatible License: MIT

  • Are you annoyed of coding .active = true while using Autolayout Anchors over and over again?
  • Are you annoyed of coding such long constraint sentence refreshView.heightAnchor.constraint(equalToConstant: self.refreshViewHeight).isActive = true over and over again?

Now EZAnchor is definitely going to shorten your time of writing Autolayout Anchors by a simple installation. Let's see how it works:

  • Anchor constraint to another anchor
//Traditional way
viewA.leadingAnchor.constraint(equalTo: viewB.leadingAnchor).isActive = true

//With EZAnchor
viewA.leading == viewB.leading
  • Anchor constraint to another anchor with constant
//Traditional way
viewA.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 10).isActive = true

//With EZAnchor
viewA.leading == self.view.leading + 10
  • Anchor constraint to another anchor with negative constant
//Traditional way
viewA.leadingAnchor.constraint(equalTo: viewB.leadingAnchor, constant: -10).isActive = true

//With EZAnchor
viewA.leading == viewB.leading - 10
  • Anchor lessThanOrEqualTo another anchor
//Traditional way
viewA.leadingAnchor.constraint(lessThanOrEqualTo: viewB.leadingAnchor).isActive = true

//With EZAnchor
viewA.leading <= viewB.leading
  • Anchor greaterThanOrEqualTo another anchor
viewA.leadingAnchor.constraint(greaterThanOrEqualTo: viewB.leadingAnchor).isActive = true

//With EZAnchor
viewA.leading >= viewB.leading
  • Anchor lessThanOrEqualTo another anchor with constant
viewA.leadingAnchor.constraint(lessThanOrEqualTo: viewB.leadingAnchor, constant: 10).isActive = true

//With EZAnchor
viewA.leading <= viewB.leading + 10
  • Anchor greaterThanOrEqualTo another anchor with constant
//Traditional way
viewA.leadingAnchor.constraint(greaterThanOrEqualTo: viewB.leadingAnchor, constant: 10).isActive = true

//With EZAnchor
viewA.leading >= viewB.leading - 10
  • Anchor equalTo another anchor with constant and multiplier
//Traditional way
viewA.heightAnchor.constraint(equalTo: viewB.heightAnchor, multiplier: 0.1, constant: -10).isActive = true

//With EZAnchor
viewA.height == viewB.height * 0.1 - 10
  • Work with Priority
//With EZAnchor
viewA.leading == (viewB.leading + 0.1) ^ .defaultLow

Installation

Drag and drop

Directly drag EZAnchor and drop into your Xcode project.

CocoaPods

To integrate EZAnchor into your Xcode project using CocoaPods, specify it in your Podfile:

target 'MyApp' do
  pod 'EZAnchor'
end

Carthage

To integrate EZAnchor into your Xcode project using Carthage, specify it in your Cartfile: coming soon

Run carthage update to build the framework and drag the built EZAnchor.framework into your Xcode project.

Demo

You can easily implement the following layout with very simple and clean code:

//set viewA's layout constraints
let viewA = UIView()
viewA.backgroundColor = UIColor.red
view.addEZSubview(viewA)
        
viewA.leading == view.leading + 5
viewA.trailing == view.trailing - 5
viewA.top == view.top + 15
viewA.centerX == view.centerX
viewA.height == view.height/2
        
//set viewB's layout constraints
let viewB = UIView()
viewB.backgroundColor = UIColor.yellow
view.addEZSubview(viewB)
        
viewB.top == viewA.bottom + 5
viewB.leading == viewA.leading
viewB.bottom == view.bottom - 5
viewB.trailing == view.centerX - 5

//set viewC's layout constraints        
let viewC = UIView()
viewC.backgroundColor = UIColor.green
view.addEZSubview(viewC)
        
viewC.top == viewB.top
viewC.bottom == viewB.bottom
viewC.leading == view.centerX + 5
viewC.trailing == viewA.trailing
        

Image of DemoScreenshot

Chaining function

Chaining way to code Autolayout with EZAnchor

viewA.setLeading(view.leading + 5)
     .setTrailing(view.trailing - 5)
     .setTop(view.top + 15)
     .setCenterX(view.centerX)
     .setHeight(view.height/2)


viewB.setTop(viewA.bottom + 5)
     .setLeading(viewA.leading)
     .setBottom(view.bottom - 5)
     .setTrailing(view.centerX - 5)

viewC.setTop(viewB.top)
     .setBottom(viewB.bottom)
     .setLeading(view.centerX + 5)
     .setTrailing(viewA.trailing)

Limitations

  1. Better to have some basic concept of anchors, familiar with coding anchors programmatically. If not please learn from this link : Programmatically Creating Constraints!

  2. Avoid defining custom UIControl or view has same name with height or width, there may have conflict with EZAnchor library

Others

WTF Autolayout will help you debug autolayout complaints.
Logo is generated with Shopify logo maker
Inspired by: PureLayout Stevia layout

Todo

  • Unit tests
  • UI Tests
  • CI
  • Fastlane

License

This code and tool is under the MIT License.

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].