TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Oct 2017 |
Maintained by Anton Bukov.
Backport of Apple NSLayoutAnchor API to iOS7 and some missings like sizeAnchor
and edgesAnchor
.
###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;
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
Anton Bukov, [email protected]
MissingAnchors is available under the MIT license. See the LICENSE file for more info.