Giter VIP home page Giter VIP logo

masonry-flattenlayout's Introduction

Masonry-FlattenLayout

Masonry is a pretty good framework of autolayout and this extension makes it better!

More ergonomic thinkable and readable code by adding some new methods: .gap() .equalTill()

Hassle

Previously, a relative layout is a point to point assignment.

An example for the [view1 mas_makeConstraints: ...]

make.right.equalTo(view2.mas_left).offset(-10)

  • The right layout constraint of view1 aligns to the particular edge, not the view.
  • And the .offset(-10) is similar so we need thinking whether positive value nor negative should be passed in.

How it should be?

Methods list:

  • New: equalTill()

    Provides a view based assignment method in flatten layout

    make.right.equalTill(view2) and make.right.equalTo(view2.mas_left) are equivalent.

    The magic of this mechanism work is .equalTill() will lookup the firstLayoutAttribute of contraint and deciding which secondLayoutAttribute should be.

    Also, make.top.equalTill(view2) and make.top.equalTo(view2.mas_bottom) are equivalent.

  • New: gap()

    Not any more negative offset value. Transforming the gap value between two views to the layout offset is on-the-fly.

    make.right.equalTo(view2.mas_left).gap(10) and make.right.equalTo(view2.mas_left).offset(-10) are equivalent.

Conclusion

Seen that? View based flatten layout gives you an easier life!

You won't confusing which edge is need in relative layout and it autocompleted with equalTill()

One more, combination the above (of course you can)

make.right.equalTo(view2.mas_left).offset(-10)

Now can be written to:

make.right.equalTill(view2).gap(10)

Installation

Use the orsome CocoaPods.

In your Podfile

pod 'Masonry-FlattenLayout'

If you want to use masonry without all those pesky 'mas_' prefixes. Add #define MAS_SHORTHAND to your prefix.pch before importing Masonry

#define MAS_SHORTHAND

Get busy Masoning

#import "Masonry-FlattenLayout.h"

TODO

  1. Send pull request to Masonry
  2. Support swift (SnapKit)
  3. .greaterOrEqualTill() and similar functions

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.