All Projects → keshavvishwkarma → Kvconstraintkit

keshavvishwkarma / Kvconstraintkit

Licence: mit
An Impressive Auto Layout DSL for iOS, tvOS & OSX. & It is written in pure swift.

Programming Languages

swift
15916 projects
dsl
153 projects

Projects that are alternatives of or similar to Kvconstraintkit

Stevia
🍃 Concise Autolayout code
Stars: ✭ 3,182 (+3396.7%)
Mutual labels:  carthage, view, layout, autolayout, constraints, auto
Core Layout
Flexbox & CSS-style Layout in Swift.
Stars: ✭ 215 (+136.26%)
Mutual labels:  carthage, layout, autolayout, constraints
Layoutframeworkbenchmark
Benchmark the performances of various Swift layout frameworks (autolayout, UIStackView, PinLayout, LayoutKit, FlexLayout, Yoga, ...)
Stars: ✭ 316 (+247.25%)
Mutual labels:  osx, tvos, layout, autolayout
Snapkit
A Swift Autolayout DSL for iOS & OS X
Stars: ✭ 18,091 (+19780.22%)
Mutual labels:  layout, autolayout, constraints, auto
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 (+4462.64%)
Mutual labels:  view, layout, autolayout, constraints
SuperPuperDuperLayout
Super puper duper mega easy awesome wrapper over auto layout!!111!!1!!!1!!!11111!!!1!!
Stars: ✭ 14 (-84.62%)
Mutual labels:  layout, constraints, auto
VanillaConstraints
🍦 Simplified and chainable AutoLayout constraints for iOS.
Stars: ✭ 42 (-53.85%)
Mutual labels:  layout, constraints, autolayout
Tangramkit
TangramKit is a powerful iOS UI framework implemented by Swift. 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,LayoutSizeClass to build your App 自动布局 UIView UITableView UICollectionView
Stars: ✭ 984 (+981.32%)
Mutual labels:  view, autolayout, constraints
EZAnchor
An easier and faster way to code Autolayout
Stars: ✭ 25 (-72.53%)
Mutual labels:  layout, constraints, autolayout
wwlayout
Swifty DSL for programmatic Auto Layout in iOS
Stars: ✭ 46 (-49.45%)
Mutual labels:  layout, constraints, autolayout
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 (+245.05%)
Mutual labels:  tvos, carthage, autolayout
Easyswiftlayout
Lightweight Swift framework for Apple's Auto-Layout
Stars: ✭ 345 (+279.12%)
Mutual labels:  layout, autolayout, constraints
Tinyconstraints
Nothing but sugar.
Stars: ✭ 3,721 (+3989.01%)
Mutual labels:  layout, constraints, auto
Easypeasy
Auto Layout made easy
Stars: ✭ 1,877 (+1962.64%)
Mutual labels:  layout, constraints, auto
Driftwood
Driftwood is a DSL to make Auto Layout easy on iOS, tvOS and macOS.
Stars: ✭ 14 (-84.62%)
Mutual labels:  tvos, constraints, autolayout
Autoinch
优雅的iPhone全尺寸/等比例精准适配工具
Stars: ✭ 395 (+334.07%)
Mutual labels:  layout, autolayout, auto
Uicollectionview Layouts Kit
📐 A set of custom layouts for UICollectionView with examples [Swift 5.3, iOS 12].
Stars: ✭ 410 (+350.55%)
Mutual labels:  layout, autolayout, constraints
Sica
🦌 Simple Interface Core Animation. Run type-safe animation sequencially or parallelly
Stars: ✭ 980 (+976.92%)
Mutual labels:  tvos, carthage
Readablebottombar
Yet another material bottom bar library for Android
Stars: ✭ 977 (+973.63%)
Mutual labels:  view, layout
Extendable
Blocks Based Bluetooth LE Connectivity framework for iOS/watchOS/tvOS/OSX. Quickly configure centrals & peripherals, perform read/write operations, and respond characteristic updates.
Stars: ✭ 88 (-3.3%)
Mutual labels:  osx, tvos

KVConstraintKit

CI Status Version Carthage compatible Swift 3.x Swift 4.x License Platform

KVConstraintKit is a DSL to make easy & impressive Auto Layout constraints on iOS, tvOS & OSX with Swift

KVConstraintKit

Installation

Using CocoaPods

  1. To integrate KVConstraintKit into your Xcode project using CocoaPods, specify it to a target in your Podfile:
use_frameworks!
pod 'KVConstraintKit', '~> 2.1'

If you want to be on the bleeding edge, replace the last line with:

pod 'KVConstraintKit', :git => 'https://github.com/keshavvishwkarma/KVConstraintKit.git', :branch => 'master'
  1. Run pod install and open the open the {Project}.xcworkspace instead of the {Project}.xcodeproj file to launch Xcode.

Using Carthage

  1. To integrate KVConstraintKit into your Xcode project using Carthage, specify it in your Cartfile:
github "keshavvishwkarma/KVConstraintKit" ~> 2.1
  1. Run carthage update and follow the additional steps in order to add KVConstraintKit to your project.

Auto Layout Attributes

KVConstraintKit supports all built-in layout attributes as of iOS, tvOS & OSX, see the NSLayoutAttribute enum.

Usage

Here's a quick example:

Without Using KVConstraintKit
let v = UIView.prepareAutoLayoutView()
v.backgroundColor = UIColor.red
view.addSubview(v)

// Prepare constraints and then add them on superview of view
let top = NSLayoutConstraint( item: v, attribute: .top,
                         relatedBy: .equal,
                            toItem: v.superview!, attribute: .top,
                        multiplier: 1.0, constant: 0)

let leading = NSLayoutConstraint( item: v, attribute: .leading,
                             relatedBy: .equal,
                                toItem: v.superview!, attribute: .leading,
                            multiplier: 1.0, constant: 0)

let trailing = NSLayoutConstraint( item: v, attribute: .trailing,
                         relatedBy: .equal,
                            toItem: v.superview!, attribute: .trailing,
                        multiplier: 1.0, constant: 0)

let bottom = NSLayoutConstraint( item: v, attribute: .bottom,
                         relatedBy: .equal,
                            toItem: v.superview!, attribute: .bottom,
                        multiplier: 1.0, constant: 0)

v.superview?.addConstraints([top, leading, trailing, bottom])
Using KVConstraintKit
v +== [.top, .leading, .trailing, .bottom]
Similarly for margin constraints
v +== [ .leadingMargin, .trailingMargin, .topMargin, .bottomMargin]

Fit

Horizontally

view.fitHorizontallyToSuperview()
OR
view.fitHorizontallyToSuperview(20) // padding

Vertically

view.fitVerticallyToSuperview()
OR
view.fitVerticallyToSuperview(20) // padding

Horizontally & Vertically

view.fitToSuperview()
OR
view.fitToSuperview(20) // width same padding for all edge

Fit with inset

let inset = UIEdgeInsets(top: 4, left: 8, bottom: 12, right: 16)    
view.fitToSuperview(contentInset:inset)

Center

Horizontally

view.applyCenterX()
OR
view.applyCenterX(20) // X offset

Vertically

view.applyCenterY()
OR
view.applyCenterY(20) // Y offset

Horizontally & Vertically

view.applyCenter()
OR
view.applyCenter(CGPoint(x:20, y:20)) // XY offset
OR
view.applyCenterX(4).applyCenterY(16) // XY offset

Size

Width

view.applyWidth(100)
OR
view.applyAtLeastWidth(100)
OR
view.applyAtMostWidth(100)

Height

view.applyHeight(100)
OR
view.applyAtLeastHeight(100)
OR
view.applyAtMostHeight(100)

Aspact Ratio

view.applyAspectRatio()

Quick Reference

Layout Attributes Using Operator Using Method
Leading (subview +== .leading).constant = 20 subview.applyLeading(20)
Trailing (subview +== .trailing).constant = 20 subview.applyTrailing(20)
Top (subview +== .top).constant = 20 subview.applyTop(20)
Bottom (subview +== .bottom).constant = 20 subview.applyBottom(20)
CenterX subview +== .centerX subview.applyCenterX()
CenterY subview +== .centerY subview.applyCenterY()
Height subview +== (.height, 100) subview.applyHeight(100)
Width subview +== (.width, 100) subview.applyWidth(100)
CenterX & CenterY subview +== [.centerX, .centerY] subview.applyCenter()

For more details see the ApplyViewConstraint extension and LayoutRelationable Protocol of KVConstraintKit.

Note: Avoid using Left and Right attributes. Use Leading and Trailing instead. This allows the layout to adapt to the view’s reading direction. By default the reading direction is determined based on the current language set by the user.

Custom Operators

The following types of operators are provided by KVConstraintKit, to add, remove, access and modify constraints.

Operator Meaning
+ to add constraint
- to remove constraint
* to modify multiplier of constraint
~ to modify Priority ( UILayoutPriority ), Relation ( NSLayoutRelation ) & Replace constraint
<- to access constraint by attributes ( eg. NSLayoutAttribute.Height )
+== to add equal relation ( NSLayoutRelation.Equal ) constraint
+>= to add greater than or equal relation ( NSLayoutRelation.GreaterThanOrEqual ) constraint
+<= to add less than or equal relation ( NSLayoutRelation.LessThanOrEqual ) constraint
*== to add equal relation constraint with multiplier
*>= to add greater than or equal relation constraint with multiplier
*<= to add less than or equal relation constraint with multiplier
|==| to add or equal relation constraint between sibling views
|>=| to add greater than or equal relation constraint between sibling views
|<=| to add less than or equal relation constraint between sibling views

License

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

Contributions

Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub.

Author

If you wish to contact me, email at: [email protected]

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