Latest 1.0.1
Homepage https://github.com/keshavvishwkarma/KVConstraintExtensionsMaster
License MIT
Platforms ios 7.0, requires ARC
Authors

KVConstraintExtensionsMaster makes auto layout constraint much easier to use from code. It provides simple, more readable, rich code reusability and powerful API for creating new, accessing, & modifying existing constraints by layout attribute.

Main motive of KVConstraintExtensionsMaster to reduce the overhead of developers while working with NSLayoutConstraint to produce responsive UI(User Interface) design.

CI Status
Version
Carthage compatible
License
Platform

Installation

Installation with CocoaPods

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects.
which automates and simplifies the process of using 3rd-party libraries in your projects.
See the Get Started section for more details.
You can install it with the following command:

$ sudo gem install cocoapods

Podfile

To integrate KVConstraintExtensionsMaster into your Xcode project using CocoaPods, simply add the following line to your Podfile:

pod "KVConstraintExtensionsMaster"

If you are using Swift, be sure to add use_frameworks! in your Podfile and set your target to iOS 8+:

platform :ios, '8.0'
use_frameworks!
pod "KVConstraintExtensionsMaster"

Then, run the following command from Terminal:

$ pod install

You should open the {Project}.xcworkspace instead of the {Project}.xcodeproj after you installed anything from CocoaPods.

$ open *.xcworkspace 

Installation with Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To install the carthage tool, you can use Homebrew or Carthage.pkg.

$ brew update
$ brew install carthage

Cartfile

To integrate KVConstraintExtensionsMaster into your Xcode project using Carthage, specify it in your Cartfile:

github "keshavvishwkarma/KVConstraintExtensionsMaster"

Then, run the following command to build the KVConstraintExtensionsMaster framework:

$ carthage update

Now drag the built KVConstraintExtensionsMaster.framework into your Xcode project.

Manually

  • Drag and drop the KVConstraintExtensionsMaster folder into your project.
  • Import the KVConstraintExtensionsMaster.h header file in class
    #import "KVConstraintExtensionsMaster.h"

    If you are using Swift, you have to import the KVConstraintExtensionsMaster.h header file In the {Project}-Bridging-Heade.h header file.

—–: Go Easy On Programatically Constraints :—-

+ Points

  • [x] No need to use more IBOutlet reference of the constraint instead of this you can directy access already applied constraint (means expected constraint) either applied Programatically or Interface Builderon any view.

  • [x] You can easily add those constraints that are not possible or very difficult from StoryBoard/xib.

  • [x] Since Constraints are cumulative & do not override to each other. if you have an existing constraint, setting another constraint of the same type does not override the previous one. So This library add any constraint only once so you don’t need to worry about what happened if we add same constraint many time.
  • [x] Easily modify any constraint and replace it with new constraint too.

  • [x] Easily modify any constraint with nice animation.

  • [x] you can easily add Proportion/Ratio constraints too in iOS 7,8,9 and later.

  • [x] you can add multiple constraints by writing few lines of code.

  • [x] All the methods of this library have prefixes prepareorapply according their behaviour. so you don’t need to remember all methods just type method prefixes then compiler automatically gives you suggestions for methods.

    A method which has prefixe prepare – is used to either prepare the constraint or prepare the view for the constraint.
    A method which has prefixe apply – is used to applyadd the constraint into its appropriate view.

##  ------: Just Two steps to ApplyAdd constraints by programatically :------

Step 1 Create & configure the view hierarchy for constraint first.

Step 2 Apply the constraints by calling KVConstraintExtensionsMaster library methods which have prefix
apply according to constraints by selected view.

@interface ViewController ()

@property (strong, nonatomic) UIView *containerView;// may be any view like /*containerView*/

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

    [self createAndConfigureViewHierarchy]; // Step 1
    [self applyConstraint];   // Step 2
}

- (void)createAndConfigureViewHierarchy
{
    self.containerView = [UIView prepareAutoLayoutView];
    self.containerView.backgroundColor = [UIColor Purple];
    [self.view addSubview:self.containerView];
}

-(void)applyConstraint
{
    // Here we are going to apply constraints
    [self.containerView applyLeadingPinConstraintToSuperview:20];
    [self.containerView applyTrailingPinConstraintToSuperview:20];

    //  we can also apply leading and trailing of containerView both by using the below method. 
        But this method is only useful when both leading and trailing have same pading.
    // [self.containerView applyLeadingAndTrailingPinConstraintToSuperview:0];

    [self.containerView applyTopPinConstraintToSuperview:65.0f];
    [self.containerView applyBottomPinConstraintToSuperview:50.0f];
}

@end

Author

Keshav Vishwkarma, [email protected]

License

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

Latest podspec

{
    "name": "KVConstraintExtensionsMaster",
    "version": "1.0.1",
    "summary": "KVConstraintExtensionsMaster is a simple auto-layout library, to apply, access or modify already added constraint on any view.",
    "description": "# KVConstraintExtensionsMaster is a simple auto-layout library, by which you can directly access or modify already applied constraint (means expected constraint) either applied programmatically or applied from Interface Builder on any view. So No need to use more IBOutlet reference.",
    "homepage": "https://github.com/keshavvishwkarma/KVConstraintExtensionsMaster",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "keshav vishwkarma": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/keshavvishwkarma/KVConstraintExtensionsMaster.git",
        "tag": "1.0.1"
    },
    "source_files": "KVConstraintExtensionsMaster/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This