Latest 0.1.0
Homepage https://github.com/doggy/Masonry-FlattenLayout
License MIT
Platforms ios 6.0, requires ARC
Dependencies Masonry
Authors

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)

TODO

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

Latest podspec

{
    "name": "Masonry-FlattenLayout",
    "version": "0.1.0",
    "summary": "More ergonomic thinkable and readable code with the new methods: .gap() .equalTill() .greaterOrEqualTill()",
    "description": "                   Masonry is good and this extension makes it better!n                   n                   Previously, an relative layout is a point to point assignment.n                   An example for the view1's mas_make:n                   - make.right.equalTo(view2.mas_left).offset(-10)n                   The right layout constraint of view1 are considered with particular edge, not with particular view.n                   The .offset(-10) is similar so we need thinking its value should be whether positive nor negative.n                   n                   * equalTill(), provides a view based assignment method in flatten layoutn                     make.right.equalTill(view2) is same as make.right.equalTo(view2.mas_left)n                     The magic of this mechanism work is .equalTill() will lookup the firstLayoutAttribute of contraint and deciding which secondLayoutAttribute should be.n                     Also, make.top.equalTill(view2) is same as make.top.equalTo(view2.mas_bottom)n                   n                   * gap(), provide a view based offset valuen                     make.right.equalTo(view2.mas_left).gap(10) is same as make.right.equalTo(view2.mas_left).offset(-10)n                   n                   Seen that? View based flatten layout gives you an easier life!n                   You won't confusing which edge is need in relative layout and it autocompleted with equalTill()n                   n                   One more, make the combination (of course you can):n                   make.right.equalTill(view2).gap(10)n",
    "homepage": "https://github.com/doggy/Masonry-FlattenLayout",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "doggy": "[email protected]"
    },
    "social_media_url": "https://www.facebook.com/lexus.lai.5",
    "platforms": {
        "ios": "6.0"
    },
    "source": {
        "git": "https://github.com/doggy/Masonry-FlattenLayout.git",
        "tag": "0.1.0"
    },
    "source_files": [
        "Masonry+FlattenLayout",
        "Masonry+FlattenLayout/**/*.{h,m}"
    ],
    "exclude_files": "Classes/Exclude",
    "requires_arc": true,
    "dependencies": {
        "Masonry": [
            "~> 0.6.3"
        ]
    }
}

Pin It on Pinterest

Share This