Skip to content

kgn/KGNAutoLayout

Repository files navigation

KGNAutoLayout

KGNAutoLayout makes AutoLayout easy!

Swift 3 Release License

Build Status Test Coverage Carthage Compatible CocoaPods Version CocoaPods Platforms

Twitter Follow Star

Installing

Carthage

github "kgn/KGNAutoLayout"

CocoaPods

pod 'KGNAutoLayout'

Examples

Example App

Example App

Pin: Superview

view.pinToEdgesOfSuperview(withOffset: 20)

pinToEdgesOfSuperview_offset20

view.pinToTopEdgeOfSuperview(withOffset: 20)

pinToTopEdgeOfSuperview_offset20

view.pinToRightEdgeOfSuperview(withOffset: 20)

pinToRightEdgeOfSuperview_offset20

view.pinToBottomEdgeOfSuperview(withOffset: 20)

pinToBottomEdgeOfSuperview_offset20

view.pinToLeftEdgeOfSuperview(withOffset: 20)

pinToLeftEdgeOfSuperview_offset20

view.pinToSideEdgesOfSuperview(withOffset: 20)

pinToSideEdgesOfSuperview_offset20

view.pinToTopAndBottomEdgesOfSuperview(withOffset: 20)

pinToTopAndBottomEdgesOfSuperview_offset20

Pin: Edges

view.pinTopEdgeToTopEdge(of: itemView, withOffset: 20)

pinTopEdgeToTopEdgeOfItem_offset20

view.pinRightEdgeToRightEdge(of: itemView, withOffset: 20)

pinRightEdgeToRightEdgeOfItem_offset20

view.pinBottomEdgeToBottomEdge(of: itemView, withOffset: 20)

pinBottomEdgeToBottomEdgeOfItem_offset20

view.pinLeftEdgeToLeftEdge(of: itemView, withOffset: 20)

pinLeftEdgeToLeftEdgeOfItem_offset20

Center

view.centerInSuperview()

centerInSuperview

view.centerHorizontallyInSuperview()

centerHorizontallyInSuperview

view.centerVerticallyInSuperview()

centerVerticallyInSuperview

[view1, view2, view3].centerHorizontally(to: parentView, withSeparation: 20)

centerViewsHorizontally_separation20

[view1, view2, view3].centerVertically(to: parentView, withSeparation: 20)

centerViewsVertically_separation20

view.centerHorizontally(to: itemView)

centerHorizontallyToItem

view.centerVertically(to: itemView)

centerVerticallyToItem

Size

view.size(toWidth: 80)

sizeToWidth80

view.size(toMinWidth: 40)

sizeToMinWidth40

view.size(toMaxWidth: 100)

sizeToMaxWidth100

view.size(toHeight: 80)

sizeToHeight80

view.size(toMinHeight: 40)

sizeToMinHeight40

view.size(toMaxHeight: 100)

sizeToMaxHeight100

view.size(toWidthAndHeight: 80)

sizeToWidthAndHeight80

view.size(toMinWidthAndHeight: 40)

sizeToMinWidthAndHeight40

view.size(toMaxWidthAndHeight: 100)

sizeToMaxWidthAndHeight100

view.sizeWidthToWidth(of: itemView)

sizeWidthToWidthOfItem

view.sizeHeightToHeight(of: itemView)

sizeHeightToHeightOfItem

view.sizeHeightToWidth(of: itemView)

sizeHeightToWidthOfItem

view.sizeWidthToHeight(of: itemView)

sizeWidthToHeightOfItem

view.sizeWidthAndHeightToWidthAndHeight(of: itemView)

sizeWidthAndHeightToWidthAndHeightOfItem

view.sizeHeightToWidth(withAspectRatio: 16/9)

sizeHeightToWidthAspectRatio16by9

view.sizeWidthToHeight(withAspectRatio: 16/9)

sizeWidthToHeightAspectRatio16by9

Position

view.positionAbove(itemView, withOffset: 20)

positionAboveItem_offset20

view.positionToTheRight(of: itemView, withOffset: 20)

positionToTheRightOfItem_offset20

view.positionBelow(itemView, withOffset: 20)

positionBelowItem_offset20

view.positionToTheLeft(of: itemView, withOffset: 20)

positionToTheLeftOfItem_offset20

[view1, view2, view3].positionAbove(itemView, withOffset: 20)

positionViewsAbove_offset20

[view1, view2, view3].positionToTheRight(of: itemView, withOffset: 20)

positionViewsToTheRight_offset20

[view1, view2, view3].positionBelow(itemView, withOffset: 20)

positionViewsBelow_offset20

[view1, view2, view3].positionToTheLeft(of: itemView, withOffset: 20)

positionViewsToTheLeft_offset20

Between

view.fitBetween(top: topView, andBottom: bottomView, withOffset: 20)

fitBetweenTopAndBottomItems_offset20

view.fitBetween(left: leftView, andRight: rightView, withOffset: 20)

fitBetweenLeftAndRightItems_offset20

Fill

parentView.fillHorizontally(withViews: [view1, view2, view3], separation: 20)

fillHorizontally_separation20

parentView.fillVertically(withViews: [view1, view2, view3], separation: 20)

fillVertically_separation20

Bound

itemView.boundHorizontally(withViews: [view1, view2, view3], separation: 20)

boundHorizontally_separation20

itemView.boundVertically(withViews: [view1, view2, view3], separation: 20)

boundVertically_separation20

itemView.boundVertically(withViews: [view1, view2, view3], separation: 20)

boundVertically_separation20

Progress:

  • Travis
  • Badges
  • Tests
  • Carthage
  • CocoaPods
  • Description
  • Documentation
  • Example App
  • AppleTV
  • Prebuilt Frameworks
  • Travis Test Matrix