mis

MissingAnchors

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

Showing:

Popularity

Downloads/wk

0

GitHub Stars

38

Maintenance

Last Commit

4yrs ago

Contributors

3

Package

Dependencies

0

License

MIT

Categories

Readme

MissingAnchors

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, k06aaa@gmail.com

License

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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100