Latest 1.2
Homepage https://github.com/suruihai/NSLayoutConstraint-SSLayout
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit
Authors
  1. simple and easy-to-use, 2files only, 17kB size.
  2. similar usage as NSLayoutAnchor, but support iOS-8 and "swiftable".
  3. 1.7 times faster than Masonry, nearly as fast as the system method.
  4. track all constraints and easy to activate/deactivate any one of them.
  5. sufficient unit tests.
  6. compatible to iOS 11, extremely easy to layout refering to safeAreaLayoutGuide.

    Example

    Setup constraints

    Notice: This method will bound all the constraints written in the block to its responsible caller.

    [self.redView activateConstraints:^{
       self.redView.height_attr.constant = 100;
       self.redView.width_attr = self.blueView.width_attr;
       self.redView.top_attr = self.blueView.top_attr;
       self.redView.leading_attr = self.blueView.trailing_attr;
    }];

    or like this

    NSMutableArray *arrayM = [NSMutableArray arrayWithCapacity:4];
    [arrayM addObject:[self.redView.height_attr equalTo:nil constant:100]];
    [arrayM addObject:[self.redView.width_attr equalTo:self.blueView.width_attr]];
    [arrayM addObject:[self.redView.top_attr equalTo:self.blueView.top_attr]];
    [arrayM addObject:[self.redView.leading_attr equalTo:self.blueView.trailing_attr]];
    [NSLayoutConstraint activateConstraints:arrayM];

    Setup constraints to safeAreaLayoutGuide

    [self.redView activateConstraints:^{
       self.redView.height_attr.constant = 100;
    self.redView.width_attr.constant = 100;
        self.redView.top_attr = self.view.top_attr_safe;
        self.redView.leading_attr = self.view.leading_attr_safe;
    }];

    Alter value of a constraint

    self.blueView.width_attr.constant = 100;

    or

    [self.redView constraintAccordingToAttribute:self.redView.height_attr].constant = 100;

    Obtain a constraint

    To use methods in UIView(SSLayout), you should have called the "activateConstraints" method in the first place so the constraints written in the block are bound to the caller, then the caller may call "constraintAccordingToAttribute" to obtain its constraints, as shown below,

    NSLayoutConstraint *cons = [self.titleLabel constraintAccordingToAttribute:self.titleLabel.bottom_attr andAttribute:self.subtitleLabel.top_attr];

    Activate/Deactivate constraint

    [self.redView activateConstraintAccordingToAttribute:self.redView.height_attr];
    [self.redView deactivateConstraintAccordingToAttribute:self.redView.height_attr];

    Notice: deactivateConstraintAccordingToAttribute will deactivate and remove the constraint object, if you desire to temporary deactivate a constraint, you should obtain it and call setActive:NO.

Adding to your project

Using CocoaPods

Add pod ‘NSLayoutConstraint-SSLayout’ to your Podfile.

Including Source Directly Into Your Project

Add the files under "Source" folder to your project.

License

This project uses MIT License.

Latest podspec

{
    "name": "NSLayoutConstraint-SSLayout",
    "version": "1.2",
    "summary": "easy-to-use NSLayoutConstraint",
    "description": "# NSLayoutConstraint-SSLayoutnsimple and easy-to-use, 2files only, 17kB size.  nsimilar usage as NSLayoutAnchor, but support iOS-8 and "swiftable".  n1.7 times faster than Masonry, nearly as fast as the system method.  ntrack all constraints and easy to activate/deactivate any one of them.n## Examplen### Setup constraintsn```n[self.redView activateConstraints:^{n        self.redView.height_attr.constant = 100;n        self.redView.width_attr = self.blueView.width_attr;n        self.redView.top_attr = self.blueView.top_attr;n        self.redView.leading_attr = self.blueView.trailing_attr;n u00a0 u00a0}];n```n### Alter value of a constraintn```nself.blueView.width_attr.constant = 100;n```n### Obtain a constraintn```nNSLayoutConstraint *cons = [self.titleLabel constraintAccordingToAttribute:self.titleLabel.bottom_attr andAttribute:self.subtitleLabel.top_attr];n```n## Adding to your projectn### Using CocoaPodsnAdd pod 'SSBannerViewController' to your Podfile.nn### Including Source Directly Into Your ProjectnAdd the files under "Source" folder to your project.nn# LicencenThis project uses MIT License.",
    "homepage": "https://github.com/suruihai/NSLayoutConstraint-SSLayout",
    "license": "MIT",
    "authors": {
        "stevenSu": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/suruihai/NSLayoutConstraint-SSLayout.git",
        "tag": "1.2"
    },
    "source_files": "Source/*.{h,m}",
    "frameworks": "UIKit",
    "requires_arc": true
}

Pin It on Pinterest

Share This