Skip to content

k06a/MissingAnchors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •