Latest 2.0.1
Homepage https://github.com/valnoc/VBAutolayout
License MIT
Platforms ios 8.1, requires ARC
Authors

There are developers (like me) who prefer to create UI programmatically due to numerous reasons. I use storyboards for segues and user scene-path. But UIViewControllers are left empty. And I do not use xibs.

When you create adaptive UI programmatically the view (or viewcontroller) code becomes unreadable because of big autolayout creation calls.

VBAutolayout is a library which makes programmatic autolayout creation comfortable, readable and code-minimized.

Format

Views layout is described in a dictionary with special VBAutolayout format. Constraints are created only for VBAutolayoutAttribute-s contained in layout dictionary. Attribute is ignored if no VBAutolayoutConstant value was given.

Layout dictionary format:

    @{VBAutolayoutAttribute: <1>,
      VBAutolayoutAttribute: <2>,
      VBAutolayoutAttribute: <3>
    }

    <1> =  <const>

    <2> =  @{VBAutolayoutItem: <item>,
             VBAutolayoutConstant: <const>}

    <3> =  @[<1>, <2>, ...]

<item> is a view2 in constraint. If no <item> specified, then superview is used and constraint is interpreted as a constraint to view container.

<const> is a string with the same format as could be used for Visual Format Constraints Creation

    <const> = <relation><constant>@<priority>, ex. 10, ==10, >=10, <=10, [email protected], >[email protected], etc.
    <relation> =    1) <, <= for <=
                    2) >, >= for >=
                    3) =, == for ==

Several constraints can be combined for one attribute using variant <3>.

Examples,

  • distance greater or equal then 10 from item top to someView bottom with 999 priority

    VBAutolayoutAttributeTop: @{VBAutolayoutItem: __someView__,`
                                VBAutolayoutConstant: @">[email protected]"}`
  • distance equal to 0 from item leading to someView trailing
    VBAutolayoutAttributeLeading: @{VBAutolayoutItem: __someView__}
  • distance equal to 0 from item leading to container leading
    VBAutolayoutAttributeLeading: @"0"

How to install

Use CocoaPods

pod 'VBAutolayout'

or

Drag VBAutolayout dir into your project.

You can import "VBAutolayout.h" into precompiled header.

License

VBAutolayout is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "VBAutolayout",
    "version": "2.0.1",
    "summary": "VBAutolayout is a library which makes programmatic autolayout creation comfortable, readable and code-minimized.",
    "description": "There are developers (like me) who prefer to create UI programmatically due to numerous reasons. I use storyboards for segues and user scene-path. But UIViewControllers are left empty. And I do not use xibs.nnWhen you create adaptive UI programmatically the view (or viewcontroller) code becomes unreadable because of big autolayout creation calls.nnVBAutolayout is a library which makes programmatic autolayout creation comfortable, readable and code-minimized.nnFormatnnViews layout is described in a dictionary with special VBAutolayout format. Constraints are created only for VBAutolayoutAttribute-s contained in layout dictionary. Attribute is ignored if no VBAutolayoutConstant value was given.nnLayout dictionary format:nn    @{VBAutolayoutAttribute: <1>,n      VBAutolayoutAttribute: <2>,n      VBAutolayoutAttribute: <3>n    }nn    <1> =  nn    <2> =  @{VBAutolayoutItem: ,n             VBAutolayoutConstant: }nn    <3> =  @[<1>, <2>, ...]nn is a view2 in constraint. If no  specified, then superview is used and constraint is interpreted as a constraint to view container.nn is a string with the same format as could be used for Visual Format Constraints Creationnn     = @, ex. 10, ==10, >=10, <=10, [email protected], >[email protected], etc.n     =    1) <, <= for <=n                    2) >, >= for >=n                    3) =, == for ==nnSeveral constraints can be combined for one attribute using variant <3>.nnExamples,nn- distance greater or equal then 10 from item top to someView bottom with 999 priorityn    VBAutolayoutAttributeTop: @{VBAutolayoutItem: __someView__,`n                                VBAutolayoutConstant: @">[email protected]"}`n- distance equal to 0 from item leading to someView trailingn    VBAutolayoutAttributeLeading: @{VBAutolayoutItem: __someView__}n- distance equal to 0 from item leading to container leadingn    VBAutolayoutAttributeLeading: @"0"",
    "homepage": "https://github.com/valnoc/VBAutolayout",
    "license": "MIT",
    "authors": {
        "Valeriy Bezuglyy": "[email protected]"
    },
    "source": {
        "git": "https://github.com/valnoc/VBAutolayout.git",
        "tag": "v2.0.1"
    },
    "platforms": {
        "ios": "8.1"
    },
    "requires_arc": true,
    "source_files": "VBAutolayout/**/*"
}

Pin It on Pinterest

Share This