Giter VIP home page Giter VIP logo

xlayout's Introduction

XLayout

🐳 XLayout is a Swift Auto Layout DSL with more lightweight syntax for macOS.

Platform Language

Requirements

  • macOS / OS X 10.10 +
  • Xcode 10.0+
  • Swift 5.0+

Installation

Git submodule

hahaha, like me. :)

Manually

Integrate XLayout into your project manually.

Issues & Contribution

  • If you need help, contact [email protected].
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

🎮 Try it Now!

Let's make some constraints like this:
DEMO

Using NSLayoutConstraint

щ(`ω´щ)
(╯-_-)╯~╩╩
m9(`Д´)
ヽ(`⌒´)ノ

Using XLayout

  • 🖇Chaining API
        view1.xLayout.leading(20).bottom(-15).width(150).height(100)
        view2.xLayout.leading(view1.trailing + 80).height(30).trailing(-15).top(40)
  • ⚖️ Equation Based API
        view1.width == 150
        view1.height == 100
        view1.leading == 20
        view1.bottom == -15
        view2.leading == view1.trailing + 80
        view2.height == 30
        view2.trailing == -15
        view2.top == 40
  • 🎨Visual Layout API
        // the | means superView and the - means space
        view1.width == 150
        view1.height == 100
        view1.visualLayout(.H(|-20-view1), .V(view1-15-|))

        view2.height == 30
        view2.visualLayout(.H(view1-80-view2-15-|), .V(|-40-view2))
  • 😎In Addition
    | : superView
    - : space
    ~ : priority
    Use them like those ways:
   view.xLayout.leading(==(contentView.leading*0.7 + 20) ~ 210)
           .trailing(<=(*0.6-50))
           .bottom(>=(contentView.bottom - 20))
           .top(contentView.top*0.8)
           .width(200)
           
   view.leading == (contentView.leading*0.7 + 20) ~ 210
   view.trailing <= *0.6-50
   view.bottom >= contentView.bottom - 20
   view.top == contentView.top*0.8
   view.width == 200

   view.visualLayout(.H(|-10-viewT-(*0.9 + 20)-|), .V(|-viewT-view))

License

XLayout is released under the MIT license. See LICENSE for details.

xlayout's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

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.