Git Product home page Git Product logo

racoonkit's Introduction

CI Status Version License Platform

RacoonKit

RacoonKit is a layout API for iOS platform. RacoonKit is written with Swift 4 and uses Apple Visual Format Language and NSLayoutConstraint SDK.

Please take a look at this article to learn more about AVF => https://www.raywenderlich.com/277-auto-layout-visual-format-language-tutorial

Installation CocoaPods

Add RacoonKit to your pod file.

pod 'RacoonKit'

Then type pod install command in project folder via terminal.

pod install

Usage

Adding subviews

You may add any UIView based components as just as an array to container view:

let newView = UIView()
let otherNewView = UIView()
view.addSubviews(views: newView, otherNewView)

Placing a view

Defining view's margins with an array in single line:

let newView = UIView()
newView.setMargins(.top(value: 8), .left(value: 8), .right(value: 8), .bottom(value: 8))

Defining a margin between two views:

newView.setMarginTo(view: otherNewView, of: .top(value: 8))
newView.setMarginTo(view: otherNewView, of: .right(value: 8))
newView.setMarginTo(view: otherNewView, of: .left(value: 8))
newView.setMarginTo(view: otherNewView, of: .bottom(value: 8))

Height and width:

newView.setHeight(100)
newView.setWidth(125)
newView.setWidthEqualToSuperview()
newView.setHeightEqualToSuperview()
newView.setWidthEqualTo(view: view)
newView.setHeightEqualTo(view: view)
newView.setWidthEqualTo(views: view, view, view)
newView.setHeightEqualTo(views: view, view, view)

Setting 'Equal' and 'Priority' to a constraint

With new RacoonFormat, you can define priority and equal properties. Use setMarginWith(formats: RacoonFormat...) method to define multiple constraints.

firstView.setMarginWith(formats: RacoonFormat(constant: .top(value: 0)))
firstView.setMarginWith(formats: RacoonFormat(constant: .left(value: 10), equality: RacoonEquality.greaterOrEqual))
firstView.setMarginWith(formats: RacoonFormat(constant: .right(value: 20), equality: RacoonEquality.lessOrEqual, priority: RacoonPriority.high))

Use RacoonFormat for setting relationships between two views:

firstView.setMarginTo(view: secondView, with: RacoonFormat(constant: .top(value: 0)))
firstView.setMarginTo(view: secondView, with: RacoonFormat(constant: .left(value: 10), equality: RacoonEquality.greaterOrEqual))
firstView.setMarginTo(view: secondView, with: RacoonFormat(constant: .right(value: 20), equality: RacoonEquality.lessOrEqual, priority: RacoonPriority.high))

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

racoonkit's People

Contributors

behrank avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

emrcftci

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.