Latest 0.6.0
Homepage https://github.com/k06a/MissingAnchors
License MIT
Platforms ios 7.0, requires ARC
Authors

CI Status
Version
Carthage compatible
License
Platform

Backport of Apple NSLayoutAnchor API to iOS7 and some missings like sizeAnchor and edgesAnchor.

Usage

Backported all default anchor methods:

  • view.leadingAnchor
  • view.trailingAnchor
  • view.leftAnchor
  • view.rightAnchor
  • view.topAnchor
  • view.bottomAnchor
  • view.widthAnchor
  • view.heightAnchor
  • view.centerXAnchor
  • view.centerYAnchor
  • view.firstBaselineAnchor
  • view.lastBaselineAnchor

Additional implemented anchors:

  • view.sizeAnchor
  • view.edgesAnchor

With some additional methods on anchors:

  • anchor.withTopAnchor
  • anchor.withBottomAnchor
  • anchor.withLeadingAnchor
  • anchor.withTrailingAnchor
  • edgesAnchor.withoutTopAnchor
  • edgesAnchor.withoutBottomAnchor
  • edgesAnchor.withoutLeadingAnchor
  • edgesAnchor.withoutTrailingAnchor

Usage example:

#import <MissingAnchors/MissingAnchors.h>

...

[view1.edgesAnchor constraintsEqualToConstant:UIEdgeInsetsMake(10, 20, 30, 40)].active = YES;
[view2.topAnchor.withBottomAnchor constraintsEqualToConstant:UIEdgeInsetsMake(10, 0, 30, 0)].active = YES;
[view3.edgesAnchor.withoutTopAnchor constraintsEqualToConstant:UIEdgeInsetsMake(0, 20, 30, 40)].active = YES;

Modern active property:

#import <MissingAnchors/MissingAnchors.h>

...

@[
   [view1.topAnchor constraintEqualToAnchor:self.view.topAnchor constant:10],
   [view1.leftAnchor constraintEqualToAnchor:self.view.leftAnchor constant:20],
   [view1.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor constant:-30],
   [view1.rightAnchor constraintEqualToAnchor:self.view.rightAnchor constant:-40],
].active = YES;

Installation

MissingAnchors is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'MissingAnchors'
pod 'MissingAnchors/NSLayoutAnchor' # if you need a backport of NSLayoutAnchor to iOS 7

Or, if you’re using Carthage, simply add MissingAnchors to your Cartfile:

github "k06a/MissingAnchors"

Author

Anton Bukov, [email protected]

License

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

Latest podspec

{
    "name": "MissingAnchors",
    "version": "0.6.0",
    "summary": "Backport of Apple NSLayoutAnchor API to iOS7 and some missings like `sizeAnchor` and `edgesAnchor`",
    "description": "Backport of Apple NSLayoutAnchor API to iOS7 and some missingsnlike `sizeAnchor` and `edgesAnchor`. Also introduced modernnpattern to create and activate several constraints.",
    "homepage": "https://github.com/k06a/MissingAnchors",
    "license": "MIT",
    "authors": {
        "Anton Bukov": "[email protected]"
    },
    "source": {
        "git": "https://github.com/k06a/MissingAnchors.git",
        "tag": "0.6.0"
    },
    "social_media_url": "https://twitter.com/k06a",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "default_subspecs": "MissingAnchors",
    "subspecs": [
        {
            "name": "MissingAnchors",
            "source_files": "Pod/Classes/*",
            "public_header_files": "Pod/Classes/*.{h}"
        },
        {
            "name": "NSLayoutAnchor",
            "source_files": "Pod/Classes/ABLayoutAnchor/*",
            "public_header_files": "Pod/Classes/ABLayoutAnchor/*.{h}"
        }
    ]
}

Pin It on Pinterest

Share This