All Projects → isair → Manuallayout

isair / Manuallayout

Licence: mit
✂ Easy to use and flexible library for manually laying out views and layers for iOS and tvOS. Supports AsyncDisplayKit.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Manuallayout

Flexlayout
FlexLayout adds a nice Swift interface to the highly optimized facebook/yoga flexbox implementation. Concise, intuitive & chainable syntax.
Stars: ✭ 1,342 (+369.23%)
Mutual labels:  layout, layout-engine
Stevia
🍃 Concise Autolayout code
Stars: ✭ 3,182 (+1012.59%)
Mutual labels:  cocoapods, layout
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]
Stars: ✭ 1,870 (+553.85%)
Mutual labels:  layout, layout-engine
Containercontroller
UI Component. This is a copy swipe-panel from app: Apple Maps, Stocks. Swift version
Stars: ✭ 273 (-4.55%)
Mutual labels:  cocoapods, layout
Fluentlayout
Stars: ✭ 23 (-91.96%)
Mutual labels:  cocoapods, layout
Allkit
🛠 Async List Layout Kit
Stars: ✭ 40 (-86.01%)
Mutual labels:  layout, layout-engine
Core Layout
Flexbox & CSS-style Layout in Swift.
Stars: ✭ 215 (-24.83%)
Mutual labels:  layout, layout-engine
Muuri React
The layout engine for React
Stars: ✭ 163 (-43.01%)
Mutual labels:  layout, layout-engine
Greedo Layout For Ios
Full aspect ratio grid layout for iOS
Stars: ✭ 837 (+192.66%)
Mutual labels:  cocoapods, layout
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 (+1351.75%)
Mutual labels:  cocoapods, layout
Fapaginationlayout
Collection view pagination layout
Stars: ✭ 276 (-3.5%)
Mutual labels:  cocoapods, layout
StackViewLayout
Coming soon!
Stars: ✭ 26 (-90.91%)
Mutual labels:  layout, layout-engine
Driveway
pure CSS masonry layouts
Stars: ✭ 607 (+112.24%)
Mutual labels:  layout, layout-engine
Framelayoutkit
FrameLayoutKit is a super fast and easy to use autolayout kit
Stars: ✭ 53 (-81.47%)
Mutual labels:  layout, layout-engine
Snapkit
A Swift Autolayout DSL for iOS & OS X
Stars: ✭ 18,091 (+6225.52%)
Mutual labels:  cocoapods, layout
TextGraphic
TextGraphic is a framework for creating Textual Graphics. It provides layers, styling, rich color, text justification, layouts, tables, view-ports, transparency, etc.
Stars: ✭ 83 (-70.98%)
Mutual labels:  layout, layout-engine
razcal
Build cross platform desktop app with Lua, MoonScript, and Layout Language
Stars: ✭ 15 (-94.76%)
Mutual labels:  layout, layout-engine
Slidecontroller
Swipe between pages with an interactive title navigation control. Configure horizontal or vertical chains for unlimited pages amount.
Stars: ✭ 279 (-2.45%)
Mutual labels:  cocoapods
Xcode One Dark
Atom One Dark theme for Xcode
Stars: ✭ 273 (-4.55%)
Mutual labels:  cocoapods
Stacks
⚡ Build React Native views blazingly fast.
Stars: ✭ 281 (-1.75%)
Mutual labels:  layout

ManualLayout CocoaPods CocoaPods

Build Status CocoaPods Gitter

Sponsor

Table of Contents

  1. Installation
  2. Usage
  3. API Cheat Sheet

Installation

Carthage

Add the following line to your Cartfile.

github "isair/ManualLayout"

Then do carthage update. After that, add the framework to your project.

CocoaPods

Add the following line in your Podfile.

pod "ManualLayout"

Usage

Just import ManualLayout in your code and use the methods and properties provided by the library to layout your views. You can check out the cheat sheet below for a compact list of everything. There are also example projects to get you started.

API Cheat Sheet

Smart Assign Operator

The smart assign operator =~ has only one job; to make your life easier.

someView.origin =~ (0, 20)
anotherView.size =~ (100, 100)
yetAnotherView.frame =~ (0, 120, view.width, 100)

CGRect/CALayer/UIView Properties

// For fast positioning.
var origin: CGPoint
var x: CGFloat 
var y: CGFloat
var center: CGPoint
var centerX: CGFloat
var centerY: CGFloat
var top: CGFloat
var right: CGFloat
var bottom: CGFloat
var left: CGFloat

// For fast sizing.
var size: CGSize
var width: CGFloat
var height: CGFloat

// Alternate edges. Their names may change in the near future.
var top2: CGFloat
var right2: CGFloat
var bottom2: CGFloat
var left2: CGFloat

The difference between alternate edges and normal edges require a bit of explaining. Imagine we have a view at position (0, 0) of size (100, 100) named myView. If we do myView.right = 200, then its position is now (100, 0) and its size remains unchaged. However, back when our view was located at (0, 0), if we had done myView.right2 = 200, then myView would have still been at (0, 0) but would have had a size of (200, 100).

So basically, setting a normal edge's position drags the whole view along with that edge but setting an alternative edge's position drags just that edge. And don't worry if you, for example, try to drag a left edge past its view's right edge. Edge swapping is done automatically so you don't have to worry about it.

UIView Methods

Just one method with two variants for now, and those are used for easy size calculations.

func sizeToFit(width: CGFloat, height: CGFloat) -> CGSize
func sizeToFit(constrainedSize: CGSize) -> CGSize

So let's say that you have a label inside a view and you want to lay it out with an inset of 4 points on all sides, you could easily do the following:

myLabel.sizeToFit(inset(myView.size, 4))
myLabel.origin =~ (4, 4)

Done!

UIScrollView Properties

var contentWidth: CGFloat
var contentHeight: CGFloat

var contentTop: CGFloat // Always equal to 0. Read-only.
var contentLeft: CGFloat // Always equal to 0. Read-only.
var contentBottom: CGFloat // contentHeight alias.
var contentRight: CGFloat // contentWidth alias.

var viewportTop: CGFloat // contentOffset.y alias.
var viewportLeft: CGFloat // contentOffset.x alias.
var viewportBottom: CGFloat // conentOffset.y + view height
var viewportRight: CGFloat // contentOffset.x + view width

UIViewController Properties

All UIViewController properties are read only. They offer easy read access to a controller's view's properties.

var bounds: CGRect

var center: CGPoint
var centerX: CGFloat
var centerY: CGFloat

var size: CGSize
var width: CGFloat
var height: CGFloat

var top: CGFloat // Top layout guide y coordinate.
var right: CGFloat // Equal to the width of the controller's view.
var bottom: CGFloat // Bottom layout guide y coordinate.
var left: CGFloat // Always equal to 0.

Helper Methods

These functions never modify the view/layer/rectangle/etc they are passed.

func inset(view: UIView, amount: CGFloat) -> CGRect
func inset(layer: CALayer, amount: CGFloat) -> CGRect
func inset(rect: CGRect, amount: CGFloat) -> CGRect

func inset(view: UIView, dx: CGFloat, dy: CGFloat) -> CGRect
func inset(layer: CALayer, dx: CGFloat, dy: CGFloat) -> CGRect
func inset(rect: CGRect, dx: CGFloat, dy: CGFloat) -> CGRect

func inset(view: UIView, top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) -> CGRect
func inset(layer: CALayer, top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) -> CGRect
func inset(rect: CGRect, top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) -> CGRect

func inset(size: CGSize, amount: CGFloat) -> CGSize
func inset(size: CGSize, dx: CGFloat, dy: CGFloat) -> CGSize
func inset(size: CGSize, top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) -> CGSize
func offset(view: UIView, amount: CGFloat) -> CGRect
func offset(layer: CALayer, amount: CGFloat) -> CGRect
func offset(rect: CGRect, amount: CGFloat) -> CGRect

func offset(view: UIView, dx: CGFloat, dy: CGFloat) -> CGRect
func offset(layer: CALayer, dx: CGFloat, dy: CGFloat) -> CGRect
func offset(rect: CGRect, dx: CGFloat, dy: CGFloat) -> CGRect

func offset(point: CGPoint, amount: CGFloat) -> CGPoint
func offset(point: CGPoint, dx: CGFloat, dy: CGFloat) -> CGPoint
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].