├── KVConstraintExtensionsExample
├── KVConstraintExtensionsExample
│ ├── en.lproj
│ │ └── InfoPlist.strings
│ ├── KV_ViewController.h
│ ├── KV_ModifyConstraintVC.h
│ ├── KV_SiblingConstraintVC.h
│ ├── KV_ApplyRatioConstraintVC.h
│ ├── KV_MultipleConstraintsVC.h
│ ├── KV_ApplySimpleConstraintVC.h
│ ├── KV_ConstraintWithAnimationVC.h
│ ├── KV_ApplySimpleRatioConstraintVC.h
│ ├── KV_ApplyLayoutGuideConstraintVC.h
│ ├── KV_ChangeStoryboardConstraintVC.h
│ ├── KV_AppDelegate.h
│ ├── KV_BaseViewController.h
│ ├── main.m
│ ├── KVConstraintExtensionsExample-Prefix.pch
│ ├── Images.xcassets
│ │ ├── LaunchImage.launchimage
│ │ │ └── Contents.json
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── KV_ChangeStoryboardConstraintVC.m
│ ├── KV_BaseViewController.m
│ ├── UIColor+KVExtensions.h
│ ├── KV_ModifyConstraintVC.m
│ ├── KVConstraintExtensionsExample-Info.plist
│ ├── KV_ApplySimpleRatioConstraintVC.m
│ ├── KV_ApplyLayoutGuideConstraintVC.m
│ ├── UIColor+KVExtensions.m
│ ├── KV_AppDelegate.m
│ ├── KV_ViewController.m
│ ├── KV_ConstraintWithAnimationVC.m
│ ├── KV_MultipleConstraintsVC.m
│ ├── KV_ApplyRatioConstraintVC.m
│ ├── KV_ApplySimpleConstraintVC.m
│ └── KV_SiblingConstraintVC.m
├── KVConstraintExtensionsExampleTests
│ ├── en.lproj
│ │ └── InfoPlist.strings
│ ├── KVConstraintExtensionsExampleTests-Info.plist
│ └── KVConstraintExtensionsExampleTests.m
├── .DS_Store
└── KVConstraintExtensionsExample.xcodeproj
│ ├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ ├── xcuserdata
│ │ └── MAC.xcuserdatad
│ │ │ ├── UserInterfaceState.xcuserstate
│ │ │ └── WorkspaceSettings.xcsettings
│ └── xcshareddata
│ │ └── KVConstraintExtensionsExample.xccheckout
│ ├── xcuserdata
│ └── MAC.xcuserdatad
│ │ ├── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── KVConstraintExtensionsExample.xcscheme
│ │ └── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ └── project.pbxproj
├── Supporting Files
├── module.modulemap
├── Info.plist
└── KVConstraintExtensionsMaster.h
├── KVConstraintExtensionsMaster.xcodeproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
├── xcshareddata
│ └── xcschemes
│ │ └── KVConstraintExtensionsMaster.xcscheme
└── project.pbxproj
├── .gitignore
├── KVConstraintExtensionsMasterTests
├── Info.plist
└── KVConstraintExtensionsMasterTests.m
├── KVConstraintExtensionsMaster.podspec
├── LICENSE
├── KVConstraintExtensionsMaster
├── KVConstraintExtensionsMaster.h
├── NSLayoutConstraint+KVConstraintExtensions.h
├── UIViewController+KVConstraintExtensions.h
├── UIViewController+KVConstraintExtensions.m
├── NSLayoutConstraint+KVConstraintExtensions.m
├── UIView+KVConstraintExtensions.h
└── UIView+KVConstraintExtensions.m
└── README.md
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExampleTests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keshavvishwkarma/KVConstraintExtensionsMaster/HEAD/KVConstraintExtensionsExample/.DS_Store
--------------------------------------------------------------------------------
/Supporting Files/module.modulemap:
--------------------------------------------------------------------------------
1 | framework module KVConstraintExtensionsMaster {
2 | umbrella header "KVConstraintExtensionsMaster.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsMaster.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample.xcodeproj/project.xcworkspace/xcuserdata/MAC.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keshavvishwkarma/KVConstraintExtensionsMaster/HEAD/KVConstraintExtensionsExample/KVConstraintExtensionsExample.xcodeproj/project.xcworkspace/xcuserdata/MAC.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ViewController.h
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 04/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_BaseViewController.h"
10 |
11 | @interface KV_ViewController : KV_BaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ModifyConstraintVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ModifyConstraintVC.h
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 24/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_BaseViewController.h"
10 |
11 | @interface KV_ModifyConstraintVC : KV_BaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_SiblingConstraintVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // KV_SiblingConstraintVC.h
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 26/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_BaseViewController.h"
10 |
11 | @interface KV_SiblingConstraintVC : KV_BaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ApplyRatioConstraintVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ApplyRatioConstraintVC.h
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 24/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_BaseViewController.h"
10 |
11 | @interface KV_ApplyRatioConstraintVC : KV_BaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_MultipleConstraintsVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // KV_MultipleConstraintsVC.h
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 24/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_BaseViewController.h"
10 |
11 | @interface KV_MultipleConstraintsVC : KV_BaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ApplySimpleConstraintVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ApplySimpleConstraintVC.h
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 24/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_BaseViewController.h"
10 |
11 | @interface KV_ApplySimpleConstraintVC : KV_BaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ConstraintWithAnimationVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ConstraintWithAnimationVC.h
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 21/09/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_BaseViewController.h"
10 |
11 | @interface KV_ConstraintWithAnimationVC : KV_BaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ApplySimpleRatioConstraintVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ApplySimpleRatioConstraintVC.h
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 8/8/16.
6 | // Copyright © 2016 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_BaseViewController.h"
10 |
11 | @interface KV_ApplySimpleRatioConstraintVC : KV_BaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ApplyLayoutGuideConstraintVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ApplyLayoutGuideConstraintVC.h
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 24/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_BaseViewController.h"
10 |
11 | @interface KV_ApplyLayoutGuideConstraintVC : KV_BaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ChangeStoryboardConstraintVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ChangeStoryboardConstraintVC.h
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 24/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_BaseViewController.h"
10 |
11 | @interface KV_ChangeStoryboardConstraintVC : KV_BaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // KV_AppDelegate.h
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 04/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface KV_AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_BaseViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // KV_BaseViewController.h
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 24/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface KV_BaseViewController : UIViewController
12 |
13 | @property (strong, nonatomic) UIView *containerView;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OS X
2 | .DS_Store
3 | *.DS_Store
4 | **/.DS_Store
5 |
6 | # Xcode
7 | */build/*
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | profile
19 | *.moved-aside
20 | DerivedData
21 | *.hmap
22 | *.ipa
23 | *.xcuserstate
24 |
25 | # Bundler
26 | .bundle
27 |
28 | #CocoaPods
29 | #Pods
30 |
31 | #Carthage
32 | Carthage/Build
33 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 04/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "KV_AppDelegate.h"
12 |
13 | int main(int argc, char * argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([KV_AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample.xcodeproj/project.xcworkspace/xcuserdata/MAC.xcuserdatad/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges
6 |
7 | SnapshotAutomaticallyBeforeSignificantChanges
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KVConstraintExtensionsExample-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_5_0
10 | #warning "This project uses features only available in iOS SDK 5.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | #import
15 | #import
16 | #import "KVConstraintExtensionsMaster.h"
17 | #import "UIColor+KVExtensions.h"
18 | #endif
19 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "portrait",
12 | "idiom" : "iphone",
13 | "subtype" : "retina4",
14 | "extent" : "full-screen",
15 | "minimum-system-version" : "7.0",
16 | "scale" : "2x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ChangeStoryboardConstraintVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ChangeStoryboardConstraintVC.m
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 24/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_ChangeStoryboardConstraintVC.h"
10 |
11 | @interface KV_ChangeStoryboardConstraintVC ()
12 |
13 | @end
14 |
15 | @implementation KV_ChangeStoryboardConstraintVC
16 |
17 | - (void)viewDidLoad
18 | {
19 | [super viewDidLoad];
20 | // Do any additional setup after loading the view.
21 | }
22 |
23 | - (void)didReceiveMemoryWarning
24 | {
25 | [super didReceiveMemoryWarning];
26 | // Dispose of any resources that can be recreated.
27 | }
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample.xcodeproj/xcuserdata/MAC.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | KVConstraintExtensionsExample.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 04A153561B6FFBDC0004D1A9
16 |
17 | primary
18 |
19 |
20 | 04A153771B6FFBDC0004D1A9
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExampleTests/KVConstraintExtensionsExampleTests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsMasterTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Supporting Files/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExampleTests/KVConstraintExtensionsExampleTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // KVConstraintExtensionsExampleTests.m
3 | // KVConstraintExtensionsExampleTests
4 | //
5 | // Created by Keshav on 04/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface KVConstraintExtensionsExampleTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation KVConstraintExtensionsExampleTests
16 |
17 | - (void)setUp
18 | {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown
24 | {
25 | // Put teardown code here. This method is called after the invocation of each test method in the class.
26 | [super tearDown];
27 | }
28 |
29 | - (void)testExample
30 | {
31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/Supporting Files/KVConstraintExtensionsMaster.h:
--------------------------------------------------------------------------------
1 | //
2 | // KVConstraintExtensionsMaster.h
3 | // KVConstraintExtensionsMaster
4 | //
5 | // Created by Keshav on 1/23/16.
6 | // Copyright © 2016 Keshav. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for KVConstraintExtensionsMaster.
12 | FOUNDATION_EXPORT double KVConstraintExtensionsMasterVersionNumber;
13 |
14 | //! Project version string for KVConstraintExtensionsMaster.
15 | FOUNDATION_EXPORT const unsigned char KVConstraintExtensionsMasterVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 | #import
20 | #import
21 | #import
22 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_BaseViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // KV_BaseViewController.m
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 24/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_BaseViewController.h"
10 |
11 | @interface KV_BaseViewController ()
12 |
13 | @end
14 |
15 | @implementation KV_BaseViewController
16 |
17 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
18 | {
19 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
20 | if (self) {
21 | // Custom initialization
22 | }
23 | return self;
24 | }
25 |
26 | - (void)viewDidLoad
27 | {
28 | [super viewDidLoad];
29 | // Do any additional setup after loading the view.
30 | }
31 |
32 | - (void)didReceiveMemoryWarning
33 | {
34 | [super didReceiveMemoryWarning];
35 | // Dispose of any resources that can be recreated.
36 | }
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsMaster.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = 'KVConstraintExtensionsMaster'
3 | s.version = '1.0.1'
4 |
5 | s.summary = 'KVConstraintExtensionsMaster is a simple auto-layout library, to apply, access or modify already added constraint on any view.'
6 | s.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.'
7 |
8 | s.homepage = 'https://github.com/keshavvishwkarma/KVConstraintExtensionsMaster'
9 | s.license = { :type => 'MIT', :file => 'LICENSE' }
10 | s.author = { "keshav vishwkarma" => "keshavvbe@gmail.com" }
11 | s.platform = :ios, '7.0'
12 | s.source = { :git => "https://github.com/keshavvishwkarma/KVConstraintExtensionsMaster.git", :tag => s.version }
13 |
14 | s.source_files = 'KVConstraintExtensionsMaster/*.{h,m}'
15 | s.requires_arc = true
16 |
17 | end
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015 Keshav Vishwkarma
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/UIColor+KVExtensions.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+KV_Addition.h
3 | // KV_LayoutDemo
4 | //
5 | // Created by Keshav on 08/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
12 | green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
13 | blue:((float)(rgbValue & 0xFF))/255.0 \
14 | alpha:1.0]
15 |
16 | @interface UIColor (KVExtensions)
17 |
18 | + (UIColor *)flatRedColor;
19 | + (UIColor *)flatDarkRedColor;
20 |
21 | + (UIColor *)Red;
22 | + (UIColor *)Pink;
23 | + (UIColor *)Purple;
24 | + (UIColor *)DeepPurple;
25 | + (UIColor *)Blue;
26 | + (UIColor *)LightBlue;
27 | + (UIColor *)Cyan;
28 | + (UIColor *)Indigo;
29 | + (UIColor *)Teal;
30 | + (UIColor *)Green;
31 | + (UIColor *)LightGreen;
32 | + (UIColor *)Lime;
33 | + (UIColor *)Yellow;
34 | + (UIColor *)Amber;
35 | + (UIColor *)DeepAmber;
36 | + (UIColor *)Orange;
37 | + (UIColor *)DeepOrange;
38 | + (UIColor *)Brown;
39 | + (UIColor *)Grey;
40 | + (UIColor *)BlueGrey;
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsMasterTests/KVConstraintExtensionsMasterTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // KVConstraintExtensionsMasterTests.m
3 | // KVConstraintExtensionsMasterTests
4 | //
5 | // Created by Keshav on 1/23/16.
6 | // Copyright © 2016 Keshav. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface KVConstraintExtensionsMasterTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation KVConstraintExtensionsMasterTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ModifyConstraintVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ModifyConstraintVC.m
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 24/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_ModifyConstraintVC.h"
10 |
11 | @interface KV_ModifyConstraintVC (){
12 | NSLayoutConstraint *constraint;
13 | }
14 |
15 | @property (strong, nonatomic) IBOutlet UIView *container;
16 |
17 | @end
18 |
19 | @implementation KV_ModifyConstraintVC
20 |
21 | // lazy constraints
22 | -(NSLayoutConstraint *)constraint{
23 | if (!constraint) {
24 | constraint = [self.container accessAppliedConstraintByAttribute:NSLayoutAttributeTop];
25 | }
26 | return constraint;
27 | }
28 |
29 | - (IBAction)panRecognizerDidFire:(UIPanGestureRecognizer *)panner
30 | {
31 | if (self.constraint) {
32 | CGFloat offset = self.constraint.constant + [panner translationInView:self.view].y;
33 | offset = MAX(0, MIN(offset, self.view.bounds.size.height));
34 | self.constraint.constant = offset;
35 | [panner setTranslation:CGPointZero inView:self.view];
36 | [self.container updateModifyConstraints];
37 | }
38 | }
39 | @end
40 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KVConstraintExtensionsExample-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | Main
29 | UIMainStoryboardFile
30 | Main
31 | UIRequiredDeviceCapabilities
32 |
33 | armv7
34 |
35 | UISupportedInterfaceOrientations
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationLandscapeLeft
39 | UIInterfaceOrientationLandscapeRight
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ApplySimpleRatioConstraintVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ApplySimpleRatioConstraintVC.m
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 8/8/16.
6 | // Copyright © 2016 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_ApplySimpleRatioConstraintVC.h"
10 |
11 | @implementation KV_ApplySimpleRatioConstraintVC
12 |
13 | - (void)viewDidLoad
14 | {
15 | [super viewDidLoad];
16 | // Do any additional setup after loading the view.
17 |
18 | /* Just Two steps to Apply\Add constraints by programatically */
19 |
20 | /* Step 1 create & configure the view hierarchy for constraint first.
21 | */
22 | [self createAndConfigureViewHierarchy];
23 |
24 | /* Step 2 Apply the constraints by calling KVConstraintExtensions library methods which have prefix "apply" according to constraints by selected view. here selected view is containerView
25 | */
26 | [self applyConstraint];
27 |
28 | }
29 |
30 | - (void)createAndConfigureViewHierarchy
31 | {
32 | self.containerView = [UIView prepareAutoLayoutView];
33 | self.containerView.backgroundColor = [UIColor Brown];
34 | [self.view addSubview:self.containerView];
35 |
36 | }
37 |
38 | - (void)applyConstraint
39 | {
40 | // Demostrate width and height Ratio Constrain programatically
41 | [self.containerView applyConstraintForCenterInSuperview];
42 | [self.containerView applyEqualWidthRatioPinConstrainToSuperview:0.6];
43 | [self.containerView applyEqualHeightRatioPinConstrainToSuperview:0.4];
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ApplyLayoutGuideConstraintVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ApplyLayoutGuideConstraintVC.m
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 24/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_ApplyLayoutGuideConstraintVC.h"
10 |
11 | @interface KV_ApplyLayoutGuideConstraintVC ()
12 |
13 | @end
14 |
15 | @implementation KV_ApplyLayoutGuideConstraintVC
16 |
17 | - (void)viewDidLoad
18 | {
19 | [super viewDidLoad];
20 | // Do any additional setup after loading the view, typically from a nib.
21 |
22 | /* Step 1 create & configure the view hierarchy for constraint first.
23 | */
24 | [self createAndConfigureViewHierarchy];
25 |
26 | /* Step 2 Apply the constraints by calling KVConstraintExtensions library methods which have prefix "apply" according to constraints by selected view.
27 | */
28 | [self applyConstraint];
29 | }
30 |
31 | - (void)createAndConfigureViewHierarchy
32 | {
33 | self.containerView = [UIView prepareAutoLayoutView];
34 | self.containerView.backgroundColor = [UIColor Purple];
35 | [self.view addSubview:self.containerView];
36 | }
37 |
38 | -(void)applyConstraint
39 | {
40 | // apply constrint with LayoutGuides of viewController
41 | [[self containerView] applyConstraintFitToSuperviewHorizontally];
42 |
43 | [self applyTopLayoutGuideConstraintToView:[self containerView] WithPadding:0];
44 |
45 | [self applyBottomLayoutGuideConstraintToView:[self containerView] WithPadding:54];
46 |
47 | // change the priority of constraint
48 | // [self.containerView changeAppliedConstraintPriority:defaultLessMaxPriority forAttribute:NSLayoutAttributeLeading];
49 | }
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsMaster/KVConstraintExtensionsMaster.h:
--------------------------------------------------------------------------------
1 | //
2 | // KVConstraintExtensions.h
3 | // https://github.com/keshavvishwkarma/KVConstraintExtensionsMaster.git
4 | //
5 | // Distributed under the MIT License.
6 | //
7 | // Copyright (c) 2015 Keshav Vishwkarma
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy of
10 | // this software and associated documentation files (the "Software"), to deal in
11 | // the Software without restriction, including without limitation the rights to
12 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13 | // of the Software, and to permit persons to whom the Software is furnished to do
14 | // so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in all
17 | // copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | // SOFTWARE.
26 | //
27 |
28 |
29 | #ifndef _KVConstraintExtensionsMaster_
30 | #define _KVConstraintExtensionsMaster_
31 |
32 | #import "UIView+KVConstraintExtensions.h"
33 | #import "UIViewController+KVConstraintExtensions.h"
34 | #import "NSLayoutConstraint+KVConstraintExtensions.h"
35 |
36 | #if DEBUG == 0
37 | #define KVLog(...)
38 | #elif DEBUG == 1
39 | #define KVLog(...) NSLog(__VA_ARGS__)
40 | #endif
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample.xcodeproj/project.xcworkspace/xcshareddata/KVConstraintExtensionsExample.xccheckout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDESourceControlProjectFavoriteDictionaryKey
6 |
7 | IDESourceControlProjectIdentifier
8 | EF8B8098-506F-48AE-9DE6-3A0FC5413FAE
9 | IDESourceControlProjectName
10 | KVConstraintExtensionsExample
11 | IDESourceControlProjectOriginsDictionary
12 |
13 | AF0766E9C80E85306E90F47CE2F98A09DCF73E5F
14 | https://github.com/keshavvishwkarma/KVConstraintExtensionsMaster.git
15 |
16 | IDESourceControlProjectPath
17 | KVConstraintExtensionsExample/KVConstraintExtensionsExample.xcodeproj
18 | IDESourceControlProjectRelativeInstallPathDictionary
19 |
20 | AF0766E9C80E85306E90F47CE2F98A09DCF73E5F
21 | ../../..
22 |
23 | IDESourceControlProjectURL
24 | https://github.com/keshavvishwkarma/KVConstraintExtensionsMaster.git
25 | IDESourceControlProjectVersion
26 | 111
27 | IDESourceControlProjectWCCIdentifier
28 | AF0766E9C80E85306E90F47CE2F98A09DCF73E5F
29 | IDESourceControlProjectWCConfigurations
30 |
31 |
32 | IDESourceControlRepositoryExtensionIdentifierKey
33 | public.vcs.git
34 | IDESourceControlWCCIdentifierKey
35 | AF0766E9C80E85306E90F47CE2F98A09DCF73E5F
36 | IDESourceControlWCCName
37 | KVConstraintExtensionsMaster
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/UIColor+KVExtensions.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+KV_Addition.m
3 | // KV_LayoutDemo
4 | //
5 | // Created by Keshav on 08/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "UIColor+KVExtensions.h"
10 |
11 | @implementation UIColor (KVExtensions)
12 |
13 | #pragma mark - Red
14 | + (UIColor *)flatRedColor {
15 | return UIColorFromRGB(0xE74C3C);
16 | }
17 | + (UIColor *)flatDarkRedColor {
18 | return UIColorFromRGB(0xC0392B);
19 | }
20 | + (UIColor *)Red {
21 | return UIColorFromRGB(0xF44336);
22 | }
23 | + (UIColor *)Pink {
24 | return UIColorFromRGB(0xE91E63);
25 | }
26 | + (UIColor *)Purple {
27 | return UIColorFromRGB(0x9C27B0);
28 | }
29 | + (UIColor *)DeepPurple {
30 | return UIColorFromRGB(0x67AB7);
31 | }
32 | + (UIColor *)Indigo {
33 | return UIColorFromRGB(0x3F51B5);
34 | }
35 | + (UIColor *)Blue {
36 | return UIColorFromRGB(0x2196F3);
37 | }
38 | + (UIColor *)LightBlue {
39 | return UIColorFromRGB(0x03A9F4);
40 | }
41 | + (UIColor *)Cyan {
42 | return UIColorFromRGB(0x00BCD4);
43 | }
44 | + (UIColor *)Teal {
45 | return UIColorFromRGB(0x009688);
46 | }
47 | + (UIColor *)Green {
48 | return UIColorFromRGB(0x4CAF50);
49 | }
50 | + (UIColor *)LightGreen {
51 | return UIColorFromRGB(0x8BC34A);
52 | }
53 | + (UIColor *)Lime {
54 | return UIColorFromRGB(0xCDDC39);
55 | }
56 | + (UIColor *)Yellow {
57 | return UIColorFromRGB(0xFFEB3B);
58 | }
59 | + (UIColor *)Amber {
60 | return UIColorFromRGB(0xFFC107);
61 | }
62 | + (UIColor *)DeepAmber {
63 | return [UIColorFromRGB(0xFFC107) colorWithAlphaComponent:0.7];
64 | }
65 | + (UIColor *)Orange {
66 | return UIColorFromRGB(0xFF9800);
67 | }
68 | + (UIColor *)DeepOrange {
69 | return UIColorFromRGB(0xFF5722);
70 | }
71 | + (UIColor *)Brown {
72 | return UIColorFromRGB(0x795548);
73 | }
74 | + (UIColor *)Grey {
75 | return UIColorFromRGB(0x9E9E9E);
76 | }
77 | + (UIColor *)BlueGrey {
78 | return UIColorFromRGB(0x607D8B);
79 | }
80 |
81 | @end
82 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // KV_AppDelegate.m
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 04/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_AppDelegate.h"
10 |
11 | @implementation KV_AppDelegate
12 |
13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
14 | {
15 | // Override point for customization after application launch.
16 | return YES;
17 | }
18 |
19 | - (void)applicationWillResignActive:(UIApplication *)application
20 | {
21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
23 | }
24 |
25 | - (void)applicationDidEnterBackground:(UIApplication *)application
26 | {
27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
29 | }
30 |
31 | - (void)applicationWillEnterForeground:(UIApplication *)application
32 | {
33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
34 | }
35 |
36 | - (void)applicationDidBecomeActive:(UIApplication *)application
37 | {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application
42 | {
43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ViewController.m
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 04/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_ViewController.h"
10 |
11 | @interface KV_ViewController ()
12 |
13 | @end
14 |
15 | @implementation KV_ViewController
16 |
17 | - (void)viewDidLoad
18 | {
19 | [super viewDidLoad];
20 | // Do any additional setup after loading the view, typically from a nib.
21 |
22 | /* Step 1 create & configure the view hierarchy for constraint first.
23 | */
24 | [self createAndConfigureViewHierarchy];
25 |
26 | /* Step 2 Apply the constraints by calling KVConstraintExtensions library methods which have prefix "apply" according to constraints by selected view.
27 | */
28 | [self applyConstraint];
29 | }
30 |
31 | - (void)createAndConfigureViewHierarchy
32 | {
33 | self.containerView = [UIView prepareAutoLayoutView];
34 | self.containerView.backgroundColor = [UIColor colorWithRed:0.95 green:0.47 blue:0.48 alpha:1.0];
35 | [self.view addSubview:self.containerView];
36 | }
37 |
38 | -(void)applyConstraint
39 | {
40 | // here we are going to apply constraints
41 | [self.containerView applyLeadingPinConstraintToSuperview:0];
42 | [self.containerView applyTrailingPinConstraintToSuperview:0];
43 |
44 | // 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 padding
45 |
46 | [self.containerView applyTopPinConstraintToSuperview:0];
47 | [self.containerView applyBottomPinConstraintToSuperview:54];
48 |
49 | //[self.containerView applyLeadingAndTrailingPinConstraintToSuperview:80];
50 |
51 | }
52 |
53 | - (IBAction)updateConstraintToggleAction:(id)sender
54 | {
55 | [self.containerView accessAppliedConstraintByAttribute:NSLayoutAttributeTrailing completion:^(NSLayoutConstraint *expectedConstraint){
56 | if (expectedConstraint) {
57 | if (expectedConstraint.constant) {
58 | expectedConstraint.constant = 0;
59 | }else{
60 | expectedConstraint.constant = -CGRectGetWidth(self.view.frame);
61 | }
62 | [self.containerView updateModifyConstraintsWithAnimation:NULL];
63 | }
64 | }];
65 | }
66 |
67 |
68 | @end
69 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsMaster/NSLayoutConstraint+KVConstraintExtensions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSLayoutConstraint+KVConstraintExtensions.h
3 | // https://github.com/keshavvishwkarma/KVConstraintExtensionsMaster.git
4 | //
5 | // Distributed under the MIT License.
6 | //
7 | // Copyright (c) 2015 Keshav Vishwkarma
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy of
10 | // this software and associated documentation files (the "Software"), to deal in
11 | // the Software without restriction, including without limitation the rights to
12 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13 | // of the Software, and to permit persons to whom the Software is furnished to do
14 | // so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in all
17 | // copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | // SOFTWARE.
26 | //
27 |
28 | #import
29 |
30 | @interface NSLayoutConstraint (KVConstraintExtensions)
31 |
32 | UIKIT_EXTERN const CGFloat defaultMultiplier;
33 | UIKIT_EXTERN const CGFloat defaultConstant;
34 | UIKIT_EXTERN const NSLayoutRelation defaultRelation;
35 | UIKIT_EXTERN const CGFloat defaultLessMaxPriority;
36 | UIKIT_EXTERN const CGFloat default_iPadRatio;
37 |
38 | + (CGFloat)defaultSpacingBetweenSiblings;
39 | + (CGFloat)defaultSpacingBetweenSuperview;
40 | + (BOOL)recognizedDirectionByAttribute:(NSLayoutAttribute)attribute toAttribute:(NSLayoutAttribute)toTttribute;
41 | /** This method is used to trace the allready added constraints on receiver view
42 | */
43 | + (NSLayoutConstraint *)appliedConstraintForView:(UIView*)aView attribute:(NSLayoutAttribute)attribute;
44 | + (BOOL)isSelfConstraintAttribute:(NSLayoutAttribute)attribute;
45 | - (BOOL)isEqualToConstraint:(NSLayoutConstraint *)aConstraint;
46 | - (NSLayoutConstraint *)swapConstraintItems;
47 | - (NSLayoutConstraint *)modifyConstraintRelatedBy:(NSLayoutRelation)relation;
48 | - (NSLayoutConstraint *)modifyConstraintMultiplierBy:(CGFloat)multiplier;
49 |
50 | @end
51 |
52 | @interface NSArray (KV_ContainsConstraint)
53 |
54 | - (NSLayoutConstraint *)containsAppliedConstraint:(NSLayoutConstraint *)appliedConstraint;
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsMaster/UIViewController+KVConstraintExtensions.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+KVConstraintExtensions.h
3 | // https://github.com/keshavvishwkarma/KVConstraintExtensionsMaster.git
4 | //
5 | // Distributed under the MIT License.
6 | //
7 | // Copyright (c) 2015 Keshav Vishwkarma
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy of
10 | // this software and associated documentation files (the "Software"), to deal in
11 | // the Software without restriction, including without limitation the rights to
12 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13 | // of the Software, and to permit persons to whom the Software is furnished to do
14 | // so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in all
17 | // copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | // SOFTWARE.
26 | //
27 |
28 | #import
29 |
30 | @interface UIViewController (KVConstraintExtensions)
31 |
32 | #pragma mark - Apply LayoutGuide Constraint From view of ViewController to a specific view
33 | /** These method is used to access applied LayoutGuide constraint from view of ViewController(self.view) to a specific view(toView).
34 | */
35 | - (void)applyTopLayoutGuideConstraintToView:(UIView * __nonnull)toView WithPadding:(CGFloat)padding NS_AVAILABLE_IOS(7_0);
36 |
37 | - (void)applyBottomLayoutGuideConstraintToView:(UIView * __nonnull)toView WithPadding:(CGFloat)padding NS_AVAILABLE_IOS(7_0);
38 |
39 | #pragma mark - Access LayoutGuide Constraint From a specific View
40 | /** This method is used to access applied LayoutGuide constraint if layout guide constraint is exist in self.view for fromView.
41 | */
42 | - (NSLayoutConstraint * __nullable)accessAppliedTopLayoutGuideConstraintFromView:(UIView * __nonnull)fromView NS_AVAILABLE_IOS(7_0);
43 |
44 | - (NSLayoutConstraint * __nullable)accessAppliedBottomLayoutGuideConstraintFromView:(UIView * __nonnull)fromView NS_AVAILABLE_IOS(7_0);
45 |
46 | #pragma mark - Remove LayoutGuide Constraints From a specific View
47 |
48 | /** These method is used to remove the layoutGuide constraint.
49 | * But you cann't remove default TopLayoutGuide and BottomLayoutGuide constraint
50 | */
51 | - (void)removeAppliedTopLayoutGuideConstraintFromView:(UIView * __nonnull)fromView NS_AVAILABLE_IOS(7_0);
52 |
53 | - (void)removeAppliedBottomLayoutGuideConstraintFromView:(UIView * __nonnull)fromView NS_AVAILABLE_IOS(7_0);
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample.xcodeproj/xcuserdata/MAC.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
18 |
30 |
31 |
32 |
34 |
46 |
47 |
48 |
50 |
62 |
63 |
64 |
66 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ConstraintWithAnimationVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ConstraintWithAnimationVC.m
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 21/09/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_ConstraintWithAnimationVC.h"
10 |
11 | @interface KV_ConstraintWithAnimationVC ()
12 |
13 | @property (strong, nonatomic) UITextField *textField;
14 | @property (strong, nonatomic) UILabel *headingLabel;
15 |
16 | @end
17 |
18 | @implementation KV_ConstraintWithAnimationVC
19 |
20 | - (void)viewDidLoad
21 | {
22 | [super viewDidLoad];
23 | // Do any additional setup after loading the view.
24 |
25 | [self createAndConfigureViewHierarchy];
26 |
27 | [self applyConstraint];
28 |
29 | }
30 |
31 | - (void)applyConstraint
32 | {
33 | [[self containerView] applyTopPinConstraintToSuperview:50.0f];
34 | [[self containerView] applyLeadingAndTrailingPinConstraintToSuperview:20];
35 | [[self containerView] applyHeightConstraint:50];
36 |
37 | [[self textField] applyConstraintFitToSuperviewContentInset:UIEdgeInsetsMake(8, 5, 4, 5)];
38 | [[self headingLabel] applyConstraintFromSiblingViewAttribute:NSLayoutAttributeCenterY toAttribute:NSLayoutAttributeCenterY ofView:[self textField] spacing:defaultConstant];
39 |
40 | [[self headingLabel] applyLeftPinConstraintToSuperview:5];
41 | [[self headingLabel] applyHeightConstraint:16.0f];
42 | }
43 |
44 | - (void)createAndConfigureViewHierarchy
45 | {
46 | self.containerView = [UIView prepareAutoLayoutView];
47 | self.containerView.backgroundColor = [UIColor Brown];
48 | [self.view addSubview:self.containerView];
49 |
50 | self.view.backgroundColor = [UIColor Red];
51 |
52 | self.textField = [UITextField prepareAutoLayoutView];
53 | self.textField.backgroundColor = [UIColor Red];
54 | self.textField.backgroundColor = [UIColor clearColor];
55 | self.textField.placeholder = @"Please enter the password.";
56 | self.textField.delegate = self;
57 |
58 | [self.containerView addSubview:self.textField];
59 |
60 | self.headingLabel = [UILabel prepareAutoLayoutView];
61 | self.headingLabel.backgroundColor = [UIColor Orange];
62 | self.headingLabel.backgroundColor = [UIColor clearColor];
63 | self.headingLabel.text = self.textField.placeholder;
64 | self.headingLabel.hidden = YES;
65 | [self.headingLabel setFont:[UIFont systemFontOfSize:12.0f]];
66 | [self.containerView addSubview:self.headingLabel];
67 | }
68 |
69 | - (void)textFieldDidBeginEditing:(UITextField *)textField
70 | {
71 | NSLayoutConstraint * constraint = [[self headingLabel] prepareConstraintFromSiblingViewAttribute:NSLayoutAttributeCenterY toAttribute:NSLayoutAttributeCenterY ofView:[self textField] multiplier:defaultMultiplier];
72 |
73 | NSLayoutConstraint *appliedConstraint = [self.containerView.constraints containsAppliedConstraint:constraint];
74 | [appliedConstraint setConstant:-CGRectGetHeight(textField.bounds)/2.0];
75 |
76 | [UIView animateWithDuration:0.25f animations:^{
77 | self.headingLabel.hidden = NO;
78 | [self.headingLabel updateModifyConstraints];
79 | } completion:NULL];
80 | }
81 |
82 | - (BOOL)textFieldShouldReturn:(UITextField *)textField
83 | {
84 | [textField resignFirstResponder];
85 |
86 | NSLayoutConstraint * constraint = [[self headingLabel] prepareConstraintFromSiblingViewAttribute:NSLayoutAttributeCenterY toAttribute:NSLayoutAttributeCenterY ofView:[self textField] multiplier:defaultMultiplier];
87 |
88 | NSLayoutConstraint *appliedConstraint = [self.containerView.constraints containsAppliedConstraint:constraint];
89 | [appliedConstraint setConstant:defaultConstant];
90 |
91 | [UIView animateWithDuration:0.2f animations:^{
92 | [self.headingLabel updateModifyConstraints];
93 | } completion:^(BOOL finished) {
94 | [UIView animateWithDuration:0.25f animations:^{
95 | self.headingLabel.hidden = YES;
96 | }];
97 | }];
98 |
99 | return YES;
100 | }
101 |
102 |
103 | @end
104 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample.xcodeproj/xcuserdata/MAC.xcuserdatad/xcschemes/KVConstraintExtensionsExample.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
61 |
62 |
68 |
69 |
70 |
71 |
72 |
73 |
79 |
80 |
86 |
87 |
88 |
89 |
91 |
92 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_MultipleConstraintsVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // KV_MultipleConstraintsVC.m
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 24/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_MultipleConstraintsVC.h"
10 |
11 | @interface KV_MultipleConstraintsVC ()
12 |
13 | @property (strong, nonatomic) UIView *secondView;
14 |
15 | @end
16 |
17 | @implementation KV_MultipleConstraintsVC
18 |
19 | - (void)viewDidLoad
20 | {
21 | [super viewDidLoad];
22 | // Do any additional setup after loading the view.
23 |
24 | /* Just Two steps to Apply\Add constraints by programatically */
25 |
26 | /* Step 1 create & configure the view hierarchy for constraint first.
27 | */
28 | [self createAndConfigureViewHierarchy];
29 |
30 | /* Step 2 Apply the constraints by calling KVConstraintExtensions library methods which have prefix "apply" according to constraints by selected view.
31 | */
32 | [self applyConstraint2];
33 | [self applyConstraint3];
34 |
35 | }
36 |
37 | - (void)createAndConfigureViewHierarchy
38 | {
39 | self.containerView = [UIView prepareAutoLayoutView];
40 | self.containerView.backgroundColor = [UIColor Brown];
41 | [self.view addSubview:self.containerView];
42 |
43 | self.secondView = [UIView prepareAutoLayoutView];
44 | self.secondView.backgroundColor = [UIColor Brown];
45 | [self.view addSubview:self.secondView];
46 |
47 | }
48 |
49 | //- (void)applyConstraint1
50 | //{
51 | // // Demostrate width and height Ratio Constrain programatically
52 | // [self.containerView applyConstraintForCenterInSuperview];
53 | // [self.containerView applyEqualWidthRatioPinConstrainToSuperview:0.6];
54 | // [self.containerView applyEqualHeightRatioPinConstrainToSuperview:0.4];
55 | //}
56 |
57 | - (void)applyConstraint2
58 | {
59 | // 1. Define the containerView Position
60 | [self.containerView applyTopPinConstraintToSuperview:20];
61 | [self.containerView applyConstraintFitToSuperviewHorizontally];
62 |
63 | CGFloat height = 80;
64 | CGFloat width = 60;
65 | CGFloat space = 16;
66 |
67 | for (NSInteger i = 0; i < 4; i++)
68 | {
69 | UIButton *contentButton = [UIButton prepareAutoLayoutView];
70 | if (i&1) {
71 | [contentButton setBackgroundColor:[UIColor Green]];
72 | }else{
73 | [contentButton setBackgroundColor:[UIColor Red]];
74 | }
75 | [contentButton.layer setBorderWidth:1.0f];
76 | [contentButton.layer setBorderColor:[UIColor Indigo].CGColor];
77 | [self.containerView addSubview:contentButton];
78 |
79 | // 2. Define the contentButton Size
80 | [contentButton applyHeightConstraint:height];
81 | [contentButton applyWidthConstraint:width];
82 |
83 | // 3. Define the contentButton Position
84 | [contentButton applyTopPinConstraintToSuperview:space];
85 | [contentButton applyBottomPinConstraintToSuperview:space];
86 | [contentButton applyLeftPinConstraintToSuperview:((i*width +(i+1)*space))];
87 | }
88 | }
89 | /*******************************
90 | * Apply multiple constraint so easily
91 | ********************/
92 |
93 | - (void)applyConstraint3
94 | {
95 | //1. this method add four constraint (in order top, left, bottom, right) by writing only single
96 | // [self.redView applyConstraintFitToSuperviewContentInset:UIEdgeInsetsMake(50, 30, 50, 20)];
97 |
98 | //2. To avoid any constraint pin top, left, bottom or right, then just simply put any value INFINITY/HUGE_VALF in contentInset because any constraint can not have INFINITY constant.
99 |
100 | [self.secondView applyConstraintFitToSuperviewContentInset:UIEdgeInsetsMake(INFINITY, 30, HUGE_VALF, 20)];
101 |
102 | // here you left two constraint Top and Bottom so view con not determine the height of the view and Y-Position of the view. So now you need to satisfied Y-Position of the view.
103 | [self.secondView applyCenterYPinConstraintToSuperview:50];
104 |
105 | // now applied constraints are sufficient but still view will not display/visible because view is not determine any height from the applied constraints so by default view set its height zero. So better is to give some height
106 | [self.secondView applyHeightConstraint:80];
107 |
108 | }
109 |
110 |
111 | @end
112 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsMaster.xcodeproj/xcshareddata/xcschemes/KVConstraintExtensionsMaster.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
53 |
54 |
64 |
65 |
71 |
72 |
73 |
74 |
75 |
76 |
82 |
83 |
89 |
90 |
91 |
92 |
94 |
95 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ApplyRatioConstraintVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ApplyRatioConstraintVC.m
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 24/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_ApplyRatioConstraintVC.h"
10 |
11 | @interface KV_ApplyRatioConstraintVC ()
12 |
13 | @property (strong, nonatomic) UIButton *button1;
14 | @property (strong, nonatomic) UIButton *button2;
15 | @property (strong, nonatomic) UIButton *button3;
16 |
17 | @end
18 |
19 | @implementation KV_ApplyRatioConstraintVC
20 |
21 | - (void)viewDidLoad
22 | {
23 | [super viewDidLoad];
24 | // Do any additional setup after loading the view.
25 |
26 | /* Just Two steps to Apply\Add constraints by programatically */
27 |
28 | /* Step 1 create & configure the view hierarchy for constraint first.
29 | */
30 | [self createAndConfigureViewHierarchy];
31 |
32 | /* Step 2 Apply the constraints by calling KVConstraintExtensions library methods which have prefix "apply" according to constraints by selected view.
33 | */
34 | [self applyVerticallyDistributedConstraintsOnButtons];
35 |
36 | }
37 |
38 | - (void)viewDidAppear:(BOOL)animated {
39 | [super viewDidAppear:animated];
40 |
41 | KVLog(@"Top space = %@",@(CGRectGetMinY(self.button1.frame)));
42 | KVLog(@"Space between button1 & button2 = %@",@(CGRectGetMinY(self.button2.frame)-CGRectGetMaxY(self.button1.frame)));
43 | KVLog(@"Space between button2 & button3 = %@",@(CGRectGetMinY(self.button3.frame)-CGRectGetMaxY(self.button2.frame)));
44 | KVLog(@"Bottom space = %@",@(CGRectGetHeight(self.containerView.frame)-CGRectGetMaxY(self.button3.frame)));
45 |
46 | }
47 |
48 | -(void)applyVerticallyDistributedConstraintsOnButtons
49 | {
50 | // setting constraint for the containerView
51 | CGFloat const padding = 6.0f;
52 |
53 | [self.containerView applyConstraintFitToSuperviewContentInset:UIEdgeInsetsMake(padding, padding, padding,padding)];
54 |
55 | // Here setting the horizontal center of buttons
56 | // means OriginX possition of view
57 | [self.button1 applyConstraintForHorizontallyCenterInSuperview];
58 | [self.button2 applyConstraintForHorizontallyCenterInSuperview];
59 | [self.button3 applyConstraintForHorizontallyCenterInSuperview];
60 |
61 | // if we not get it then we needs to calculate it dynamically by text or something else
62 | CGFloat const buttonHeight = 34.0f;
63 | CGFloat const numberOfButtons = 3.0f;
64 |
65 | // here setting OriginY possition of view in percentaage.
66 | [self.button1 applyCenterYRatioPinConstrainToSuperview:(defaultMultiplier-(1.0f/(numberOfButtons-1))) padding:-(buttonHeight/(numberOfButtons+1))];
67 |
68 | [self.button2 applyConstraintForVerticallyCenterInSuperview];
69 |
70 | [self.button3 applyCenterYRatioPinConstrainToSuperview:(defaultMultiplier+(1.0f/(numberOfButtons-1))) padding:(buttonHeight/(numberOfButtons+1))];
71 |
72 | [self.containerView updateModifyConstraints];
73 | }
74 |
75 |
76 | -(void)distributeVerticallyButtons
77 | {
78 | // seting constraint for containner view
79 | [self.containerView applyConstraintFitToSuperview];
80 |
81 | // if we have not got height of button then we needs to calculate it dynamically by text or something else
82 | CGFloat const buttonHeight = 34.0f;
83 | CGFloat const numberOfButtons = 3.0f;
84 |
85 | NSArray *buttons = @[self.button1,self.button2,self.button3];
86 |
87 | NSInteger middelIndex = floorf((buttons.count/2.0f));
88 |
89 | // reference view to distrybute other view
90 | [buttons[middelIndex] applyConstraintForCenterInSuperview];
91 |
92 | // processing for after midel button list
93 | while ( (middelIndex +1)< buttons.count)
94 | {
95 | [buttons[++middelIndex] applyCenterYRatioPinConstrainToSuperview:(defaultMultiplier+(1.0f/(numberOfButtons-1))) padding:(buttonHeight/(numberOfButtons+1))];
96 | [buttons[middelIndex] applyConstraintForHorizontallyCenterInSuperview];
97 | }
98 |
99 | middelIndex = floorf((buttons.count/2.0f));
100 | // processing for before midel button list
101 | while ((middelIndex - 1) != -1)
102 | {
103 | [buttons[--middelIndex] applyCenterYRatioPinConstrainToSuperview:(defaultMultiplier-(1.0f/(numberOfButtons-1))) padding:-(buttonHeight/(numberOfButtons+1))];
104 |
105 | [buttons[middelIndex] applyConstraintForHorizontallyCenterInSuperview];
106 | }
107 |
108 | [self.containerView updateModifyConstraints];
109 | }
110 |
111 |
112 | - (void)createAndConfigureViewHierarchy
113 | {
114 | self.containerView = [UIView prepareAutoLayoutView];
115 | self.containerView.backgroundColor = [UIColor Teal];
116 | [self.view addSubview:self.containerView];
117 |
118 | self.button1 = [UIButton prepareAutoLayoutView];
119 | self.button1.backgroundColor = [UIColor Red];
120 | [self.containerView addSubview:self.button1];
121 |
122 | self.button2 = [UIButton prepareAutoLayoutView];
123 | self.button2.backgroundColor = [UIColor Green];
124 | [self.containerView addSubview:self.button2];
125 |
126 | self.button3 = [UIButton prepareAutoLayoutView];
127 | self.button3.backgroundColor = [UIColor Brown];
128 | [self.containerView addSubview:self.button3];
129 |
130 | [self.button1 setTitle:@"button1" forState:UIControlStateNormal];
131 | [self.button2 setTitle:@"button2" forState:UIControlStateNormal];
132 | [self.button3 setTitle:@"button3" forState:UIControlStateNormal];
133 |
134 | }
135 |
136 | @end
137 |
138 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_ApplySimpleConstraintVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // KV_ApplySimpleConstraintVC.m
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 24/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_ApplySimpleConstraintVC.h"
10 |
11 | @interface KV_ApplySimpleConstraintVC ()
12 |
13 | @end
14 |
15 | @implementation KV_ApplySimpleConstraintVC
16 |
17 | - (void)viewDidLoad
18 | {
19 | [super viewDidLoad];
20 |
21 | /**************------Go Easy on Programatically constraints ------************/
22 |
23 | /* Just Two steps to Apply\Add constraints by programatically */
24 |
25 | /* Step 1 create & configure the view hierarchy for constraint first.
26 | */
27 | [self createAndConfigureViewHierarchy];
28 |
29 | /* Step 2 Apply the constraints by calling KVConstraintExtensions library methods which have prefix "apply" according to constraints by selected view.
30 | */
31 | // NOTE:- Read at least once it would be better for you.
32 |
33 | [self applyConstraints1];
34 | // [self applyConstraints2];
35 |
36 | }
37 |
38 | -(void)applyConstraints1
39 | {
40 | // Now we need to apply constraint on the view so first select view on which you want to add constraints.
41 | // here selected view is constainerView. we are going to add constraints on the constainerView
42 | // so we need to call methods which have prefix apply according to constraints by selected view.
43 |
44 | /******* Apply single constraint one by one in any view( containerView ) ************/
45 | // set top pin constraint
46 | [self.containerView applyTopPinConstraintToSuperview:40];
47 | // set bottom pin constraint
48 | [self.containerView applyBottomPinConstraintToSuperview:40];
49 | // set Leading pin constraint
50 | [self.containerView applyLeadingPinConstraintToSuperview:30];
51 | // set Trailing pin constraint
52 | [self.containerView applyTrailingPinConstraintToSuperview:20];
53 |
54 | // You can also apply the same leading and trailling by wrtting single line
55 | // so if both side spacing/padding same then you can use below methos
56 | // wich is Equal above applyLeadingPin and applyTrailingPin methods
57 | // [self.containerView applyLeadingAndTrailingPinConstraintToSuperview:20];
58 |
59 | }
60 |
61 | -(void)applyConstraints2
62 | {
63 | // Applying the same leading and trailling by wrtting single line of code.
64 | [self.containerView applyTopAndBottomPinConstraintToSuperview:40];
65 |
66 | // using view left & Right alignment instead of leading and trailling.
67 | [self.containerView applyLeftPinConstraintToSuperview:30];
68 | [self.containerView applyRightPinConstraintToSuperview:30];
69 |
70 | // NOTE:- Read at least once it would be better for you.
71 |
72 | /*
73 | // LeadingPin constraint will have all most same layout effect as leftPin constraint can have.
74 | // Similarly trailingPin constraint will have all most same layout effect as rightPin constraint can have.
75 | // But in the constraints, leadingPin constraints is deferent from leftPin constraint and
76 | // TrailingPin constraints is deferent from rightPin constraint.
77 |
78 | // So we should be careful, when we are applying both constraints leadingPin and leftPin of a same view(superview) and constraints trailingPin and rightPin of a same view(superview).
79 |
80 | // Why we will careful ? because -
81 | // Case 1:
82 | // when you apply both leadingPin and leftPin constraints of a same view then view can have conflict.
83 | // if constraint padding(constant value) is same then no conflict other wise view must have conflict.
84 | // and it will break the view constraint and then you have got some error in console
85 |
86 | // Similarly Case 2:
87 | // when you apply both trailingPin and rightPin constraints of a same view then view can have conflict
88 | // if and only if constraint padding(constant value) is deferent. other wise no conflict.
89 |
90 | // if you have conflict then auto layout engine will break the constraints of view and let you know the reason with log in the console.
91 | EX;- Call both methos in viewDidLoad with deferent padding
92 |
93 | Either
94 | [self.containerView applyLeftPinConstraintToSuperview:30];
95 | [self.containerView applyLeadingAndTrailingPinConstraintToSuperview:20];
96 | OR
97 | [self.containerView applyTrailingPinConstraintToSuperview:20];
98 | [self.containerView applyRightPinConstraintToSuperview:30];
99 |
100 |
101 | // Now you have got something like below in console log -
102 | (
103 | "",
104 | ""
105 | )
106 | Here one constraint try to set let position of containerView by 20 Px and other constraint try to set let position of containerView by 30 Px So thats a constraint conflict.
107 | to resolve this constraint we needs to set the priority of constraint with the help of priority auto-layout engine it self decide which constraint is less important to left.
108 |
109 | But in case, both constraints padding/spacing is same then there is no conflict because
110 | both are trying to set same position of containerView that possible.
111 |
112 | Same case will also happen with trailingPin and rightPin constraints try it yourself to understand.
113 |
114 | */
115 |
116 | }
117 |
118 | - (void)createAndConfigureViewHierarchy
119 | {
120 | [self.view setBackgroundColor:[UIColor Teal]];
121 |
122 | self.containerView = [UIView prepareAutoLayoutView];
123 | self.containerView.backgroundColor = [UIColor Green];
124 | [self.view addSubview:self.containerView];
125 | }
126 |
127 | @end
128 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsMaster/UIViewController+KVConstraintExtensions.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+KVConstraintExtensions.m
3 | // https://github.com/keshavvishwkarma/KVConstraintExtensionsMaster.git
4 | //
5 | // Distributed under the MIT License.
6 | //
7 | // Copyright (c) 2015 Keshav Vishwkarma
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy of
10 | // this software and associated documentation files (the "Software"), to deal in
11 | // the Software without restriction, including without limitation the rights to
12 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13 | // of the Software, and to permit persons to whom the Software is furnished to do
14 | // so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in all
17 | // copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | // SOFTWARE.
26 | //
27 |
28 | #import "KVConstraintExtensionsMaster.h"
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | @implementation UIViewController (KVConstraintExtensions)
33 |
34 | #pragma mark - common private Layout Guide constraint methods
35 | // to create
36 | - (NSLayoutConstraint * __nullable)prepareLayoutGuideConstraintToView:(UIView * __nonnull)toView WithPadding:(CGFloat)padding isTopLayoutGuide:(BOOL)isTopLayoutGuide {
37 | NSLayoutConstraint *preparedConstraint = nil;
38 | [toView prepareAutoLayoutView];
39 |
40 | NSAssert(([self view] != toView), @"you are passing wrong view and fromView must not be distinct from self.view of ViewController.");
41 | NSAssert(toView, @"fromView must not be nil.");
42 |
43 | if (isTopLayoutGuide) {
44 | preparedConstraint = [NSLayoutConstraint constraintWithItem:toView attribute:NSLayoutAttributeTop relatedBy:defaultRelation toItem:self.topLayoutGuide attribute:NSLayoutAttributeBottom multiplier:defaultMultiplier constant:padding];
45 | }
46 | else{
47 | preparedConstraint = [NSLayoutConstraint constraintWithItem:self.bottomLayoutGuide attribute:NSLayoutAttributeTop relatedBy:defaultRelation toItem:toView attribute:NSLayoutAttributeBottom multiplier:defaultMultiplier constant:padding];
48 | }
49 |
50 | return preparedConstraint;
51 | }
52 |
53 | - (NSLayoutConstraint * __nullable)accessAppliedLayoutGuideConstraintFromView:(UIView * __nonnull)fromView isTopLayoutGuide:(BOOL)isTopLayoutGuide
54 | {
55 | __block NSLayoutConstraint *appliedConstraint = nil;
56 | __block idlayoutGuide = isTopLayoutGuide ? self.topLayoutGuide : self.bottomLayoutGuide;
57 | NSLayoutAttribute viewAttribute = isTopLayoutGuide ? NSLayoutAttributeTop : NSLayoutAttributeBottom;
58 | NSLayoutAttribute layoutGuideAttribute = isTopLayoutGuide ? NSLayoutAttributeBottom : NSLayoutAttributeTop;
59 |
60 | [self.view.constraints enumerateObjectsUsingBlock: ^(NSLayoutConstraint *constraint, NSUInteger idx, BOOL *stop)
61 | {
62 | if ( ((constraint.firstItem == layoutGuide)&&(constraint.secondItem == fromView)) || ((constraint.secondItem == layoutGuide)&&(constraint.firstItem == fromView)) )
63 | {
64 | if (self.view == fromView) {
65 | if (NSLayoutAttributeTop == (constraint.firstAttribute|constraint.secondAttribute)) {
66 | appliedConstraint = constraint;
67 | }else if (NSLayoutAttributeBottom == (constraint.firstAttribute|constraint.secondAttribute)) {
68 | appliedConstraint = constraint;
69 | }else{
70 | KVLog(@"NOT Found");
71 | }
72 | }
73 | else if (((constraint.firstItem == layoutGuide) && (constraint.firstAttribute == layoutGuideAttribute)) && ((constraint.secondItem == fromView) && (constraint.secondAttribute == viewAttribute))) {
74 | appliedConstraint = constraint;
75 | } else if (((constraint.secondItem == layoutGuide) && (constraint.secondAttribute == layoutGuideAttribute)) && ((constraint.firstItem == fromView) && (constraint.firstAttribute == viewAttribute))) {
76 | appliedConstraint = constraint;
77 | } else {
78 | KVLog(@"NOT Found");
79 | }
80 | }
81 | }];
82 |
83 | return appliedConstraint;
84 | }
85 |
86 |
87 | - (void)applyTopLayoutGuideConstraintToView:(UIView * __nonnull)toView WithPadding:(CGFloat)padding {
88 | NSLayoutConstraint *preparedConstraint = [self prepareLayoutGuideConstraintToView:toView WithPadding:padding isTopLayoutGuide:YES];
89 | [self.view applyPreparedConstraintInView:preparedConstraint];
90 | }
91 |
92 | - (void)applyBottomLayoutGuideConstraintToView:(UIView * __nonnull)toView WithPadding:(CGFloat)padding {
93 | NSLayoutConstraint *preparedConstraint = [self prepareLayoutGuideConstraintToView:toView WithPadding:padding isTopLayoutGuide:NO];
94 | [self.view applyPreparedConstraintInView:preparedConstraint];
95 | }
96 |
97 | - (NSLayoutConstraint * __nullable)accessAppliedTopLayoutGuideConstraintFromView:(UIView * __nonnull)fromView{
98 | return [self accessAppliedLayoutGuideConstraintFromView:fromView isTopLayoutGuide:YES];
99 | }
100 |
101 | - (NSLayoutConstraint * __nullable)accessAppliedBottomLayoutGuideConstraintFromView:(UIView * __nonnull)fromView{
102 | return [self accessAppliedLayoutGuideConstraintFromView:fromView isTopLayoutGuide:NO];
103 | }
104 |
105 | - (void)removeAppliedTopLayoutGuideConstraintFromView:(UIView * __nonnull)fromView {
106 | if (self.view != fromView)
107 | {
108 | NSLayoutConstraint *appliedConstraint = [self accessAppliedTopLayoutGuideConstraintFromView:fromView];
109 | if (appliedConstraint) [self.view removeConstraint:appliedConstraint];
110 | }
111 | }
112 |
113 | - (void)removeAppliedBottomLayoutGuideConstraintFromView:(UIView * __nonnull)fromView {
114 | if (self.view != fromView){
115 | NSLayoutConstraint *appliedConstraint = [self accessAppliedBottomLayoutGuideConstraintFromView:fromView];
116 | if (appliedConstraint) [self.view removeConstraint:appliedConstraint];
117 | }
118 | }
119 |
120 | @end
121 |
122 | NS_ASSUME_NONNULL_END
123 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # KVConstraintExtensionsMaster
2 |
3 | `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.
4 |
5 | Main motive of `KVConstraintExtensionsMaster` to reduce the overhead of developers while working with `NSLayoutConstraint` to produce `responsive UI(User Interface) design`.
6 |
7 | [](https://travis-ci.org/keshavvishwkarma/KVConstraintExtensionsMaster)
8 | [](http://cocoapods.org/pods/KVConstraintExtensionsMaster)
9 | [](https://github.com/Carthage/Carthage)
10 | [](http://cocoapods.org/pods/KVConstraintExtensionsMaster)
11 | [](http://cocoapods.org/pods/KVConstraintExtensionsMaster)
12 |
13 | ## Installation
14 |
15 | ### Installation with CocoaPods
16 |
17 | [CocoaPods](http://cocoapods.org) is a dependency manager for Swift and Objective-C Cocoa projects.
18 | which automates and simplifies the process of using 3rd-party libraries in your projects.
19 | See the [Get Started](https://cocoapods.org/#get_started) section for more details.
20 | You can install it with the following command:
21 |
22 | ``` bash
23 | $ sudo gem install cocoapods
24 | ```
25 | #### Podfile
26 |
27 | To integrate KVConstraintExtensionsMaster into your Xcode project using [CocoaPods](http://cocoapods.org), simply add the following line to your `Podfile`:
28 |
29 | ```ruby
30 | pod "KVConstraintExtensionsMaster"
31 | ```
32 | > If you are using `Swift`, be sure to add `use_frameworks!` in your `Podfile` and set your target to iOS 8+:
33 |
34 | ```
35 | platform :ios, '8.0'
36 | use_frameworks!
37 | pod "KVConstraintExtensionsMaster"
38 | ```
39 |
40 | Then, run the following command from Terminal:
41 |
42 | ```
43 | $ pod install
44 | ```
45 | You should open the `{Project}.xcworkspace` instead of the `{Project}.xcodeproj` after you installed anything from CocoaPods.
46 |
47 | ```
48 | $ open *.xcworkspace
49 | ```
50 |
51 | ### Installation with Carthage
52 |
53 | [Carthage](https://github.com/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](http://brew.sh) or [Carthage.pkg](https://github.com/Carthage/Carthage/releases).
54 |
55 | ``` bash
56 | $ brew update
57 | $ brew install carthage
58 | ```
59 | #### Cartfile
60 |
61 | To integrate KVConstraintExtensionsMaster into your Xcode project using Carthage, specify it in your `Cartfile`:
62 |
63 | ``` ogdl
64 | github "keshavvishwkarma/KVConstraintExtensionsMaster"
65 | ```
66 |
67 | Then, run the following command to build the `KVConstraintExtensionsMaster` framework:
68 | ``` bash
69 | $ carthage update
70 | ```
71 | Now drag the built `KVConstraintExtensionsMaster.framework` into your Xcode project.
72 |
73 | ``` Manually ```
74 | -----
75 |
76 | - Drag and drop the KVConstraintExtensionsMaster folder into your project.
77 | - Import the KVConstraintExtensionsMaster.h header file in class
78 | ```objective-c
79 | #import "KVConstraintExtensionsMaster.h"
80 | ```
81 | > If you are using Swift, you have to import the ```KVConstraintExtensionsMaster.h``` header file In the ```{Project}-Bridging-Heade.h``` header file.
82 |
83 | ## -----: Go Easy On Programatically Constraints :----
84 | ### ``` + Points ```
85 |
86 | - [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 Builder ```on any view.
87 |
88 | - [x] You can easily add those constraints that are not ``` possible or very difficult from StoryBoard/xib```.
89 |
90 | - [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.
91 | - [x] Easily ``` modify ``` any constraint and ``` replace ``` it with new constraint too.
92 |
93 | - [x] Easily ``` modify ``` any constraint with nice animation.
94 |
95 | - [x] you can easily ``` add Proportion/Ratio ``` constraints too in iOS 7,8,9 and later.
96 |
97 | - [x] you can ``` add multiple ``` constraints by writing few lines of code.
98 |
99 | - [x] All the methods of this library have prefixes ``` prepare ```or``` apply ``` according their behaviour. so you don't need to remember all methods just type method prefixes then ``` compiler automatically``` gives you ``` suggestions ``` for methods.
100 |
101 | A method which has prefixe ``` prepare ``` - is used to either prepare the constraint or prepare the view for the constraint.
102 | A method which has prefixe ``` apply ``` - is used to apply\add the constraint into its appropriate view.
103 |
104 |
105 | ```
106 | ## ------: Just Two steps to Apply\Add constraints by programatically :------
107 | ```
108 | ``` Step 1 ``` Create & configure the view hierarchy for constraint first.
109 |
110 | ``` Step 2 ``` Apply the constraints by calling KVConstraintExtensionsMaster library methods which have prefix
111 | ``` apply ``` according to constraints by selected view.
112 |
113 | ```
114 | @interface ViewController ()
115 |
116 | @property (strong, nonatomic) UIView *containerView;// may be any view like /*containerView*/
117 |
118 | @end
119 |
120 | @implementation ViewController
121 |
122 | - (void)viewDidLoad
123 | {
124 | [super viewDidLoad];
125 | // Do any additional setup after loading the view, typically from a nib.
126 |
127 | [self createAndConfigureViewHierarchy]; // Step 1
128 | [self applyConstraint]; // Step 2
129 | }
130 |
131 | - (void)createAndConfigureViewHierarchy
132 | {
133 | self.containerView = [UIView prepareAutoLayoutView];
134 | self.containerView.backgroundColor = [UIColor Purple];
135 | [self.view addSubview:self.containerView];
136 | }
137 |
138 | -(void)applyConstraint
139 | {
140 | // Here we are going to apply constraints
141 | [self.containerView applyLeadingPinConstraintToSuperview:20];
142 | [self.containerView applyTrailingPinConstraintToSuperview:20];
143 |
144 | // we can also apply leading and trailing of containerView both by using the below method.
145 | But this method is only useful when both leading and trailing have same pading.
146 | // [self.containerView applyLeadingAndTrailingPinConstraintToSuperview:0];
147 |
148 | [self.containerView applyTopPinConstraintToSuperview:65.0f];
149 | [self.containerView applyBottomPinConstraintToSuperview:50.0f];
150 | }
151 |
152 | @end
153 |
154 | ```
155 |
156 | ## Author
157 |
158 | Keshav Vishwkarma, keshavvbe@gmail.com
159 |
160 | ## License
161 |
162 | KVConstraintExtensionsMaster is available under the MIT license. See the LICENSE file for more info.
163 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample/KV_SiblingConstraintVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // KV_SiblingConstraintVC.m
3 | // KVConstraintExtensionsExample
4 | //
5 | // Created by Keshav on 26/08/15.
6 | // Copyright (c) 2015 Keshav. All rights reserved.
7 | //
8 |
9 | #import "KV_SiblingConstraintVC.h"
10 |
11 | @interface KV_SiblingConstraintVC ()
12 |
13 | @property (strong, nonatomic) UIView *firstView;
14 | @property (strong, nonatomic) UIView *secondView;
15 | @property (strong, nonatomic) UIView *thirdView;
16 |
17 | @end
18 |
19 | @implementation KV_SiblingConstraintVC
20 |
21 | - (void)viewDidLoad
22 | {
23 | [super viewDidLoad];
24 | // Do any additional setup after loading the view, typically from a nib.
25 |
26 | /* Step 1 create & configure the view hierarchy for constraint first.
27 | */
28 | [self createAndConfigureViewHierarchy];
29 |
30 | /* Step 2 Apply the constraints by calling KVConstraintExtensions library methods which have prefix "apply" according to constraints by selected view.
31 | */
32 | [self applyConstraint];
33 |
34 | // for scrollView
35 | [self configureScrollViewHierarchyAndApplyConstraint];
36 | }
37 |
38 |
39 | -(void)applyConstraint
40 | {
41 | // here setting the constraints for containerView
42 | [self.containerView applyConstraintForHorizontallyCenterInSuperview];
43 |
44 | [self.containerView applyCenterYPinConstraintToSuperview:60];
45 |
46 | // this method is only used to increase the Constant Value of the CenterY constraint on Ipad with its Ratio
47 |
48 | [self.containerView updateAppliedConstraintConstantValueForIpadByAttribute:NSLayoutAttributeCenterY];
49 |
50 | [self.containerView applyEqualHeightRatioPinConstrainToSuperview:0.5];
51 | [self.containerView applyEqualWidthRatioPinConstrainToSuperview:0.7];
52 |
53 | [self.firstView applyLeadingPinConstraintToSuperview:16];
54 | [self.thirdView applyTrailingPinConstraintToSuperview:16];
55 |
56 | // here setting the Top & Bottom constraints for firstView
57 | [self.firstView applyTopAndBottomPinConstraintToSuperview:20];
58 | // here setting the Top & Bottom constraints for secondView
59 | [self.secondView applyTopAndBottomPinConstraintToSuperview:30];
60 | // here setting the Top & Bottom constraints for thirdView
61 | [self.thirdView applyTopAndBottomPinConstraintToSuperview:40];
62 |
63 | // now here setting the Horizontal space between the views
64 |
65 | // These constraint in left to right that means that is positive direction
66 | [_firstView applyConstraintFromSiblingViewAttribute:NSLayoutAttributeRight toAttribute:NSLayoutAttributeLeft ofView:_secondView spacing:16];
67 |
68 | [_secondView applyConstraintFromSiblingViewAttribute:NSLayoutAttributeRight toAttribute:NSLayoutAttributeLeft ofView:_thirdView spacing:16];
69 |
70 | // now here setting the equal width constraints for all subviews of containerView.
71 | [_firstView applyConstraintFromSiblingViewAttribute:NSLayoutAttributeWidth toAttribute:NSLayoutAttributeWidth ofView:_secondView spacing:0];
72 | [_secondView applyConstraintFromSiblingViewAttribute:NSLayoutAttributeWidth toAttribute:NSLayoutAttributeWidth ofView:_thirdView spacing:0];
73 |
74 |
75 | // Here we are trying to accessing the constraints between sibling views
76 | // NSLayoutConstraint *appliedConstrint = [_secondView accessAppliedConstraintFromSiblingViewByAttribute:NSLayoutAttributeRight toAttribute:NSLayoutAttributeLeft ofView:_thirdView];
77 |
78 | // KVLog(@"%@",appliedConstrint);
79 |
80 | }
81 |
82 | - (void)createAndConfigureViewHierarchy
83 | {
84 | // here creating views
85 | self.containerView = [UIView prepareAutoLayoutView];
86 | self.containerView.backgroundColor = [UIColor Brown];
87 |
88 | self.firstView = [UIView prepareAutoLayoutView];
89 | self.firstView.backgroundColor = [UIColor Green];
90 |
91 | self.secondView = [UIView prepareAutoLayoutView];
92 | self.secondView.backgroundColor = [UIColor Red];
93 |
94 | self.thirdView = [UIView prepareAutoLayoutView];
95 | self.thirdView.backgroundColor = [UIColor Teal];
96 |
97 | // Here configuring view hierarchy
98 | [self.containerView addSubview:self.firstView];
99 | [self.containerView addSubview:self.secondView];
100 | [self.containerView addSubview:self.thirdView];
101 |
102 | [self.view addSubview:self.containerView];
103 |
104 | }
105 |
106 |
107 | - (void)configureScrollViewHierarchyAndApplyConstraint
108 | {
109 | UIScrollView *scrollView = [UIScrollView prepareAutoLayoutView];
110 | scrollView.backgroundColor = [UIColor Brown];
111 |
112 | [self.view addSubview:scrollView];
113 | UIView *containerView = [UIView prepareAutoLayoutView];
114 | containerView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.95];
115 |
116 | [scrollView addSubview:containerView];
117 |
118 | CGFloat space = 8;
119 |
120 | UIEdgeInsets contentInset = UIEdgeInsetsMake(20, space, HUGE_VALF, space);
121 | [scrollView applyConstraintFitToSuperviewContentInset:contentInset];
122 | [scrollView applyHeightConstraint:100];
123 |
124 | // this method is only used to increase the Constant Value of the height constraint on Ipad with its Ratio
125 | [scrollView updateAppliedConstraintConstantValueForIpadByAttribute:NSLayoutAttributeHeight];
126 |
127 | // 1. Define the containerView y Position and height
128 | [containerView applyConstraintForVerticallyCenterInSuperview];
129 |
130 | // Here I'm applying the height constraints based on ratio
131 | [containerView applyEqualHeightRatioPinConstrainToSuperview:(1-(2*space)*0.01)];
132 |
133 | // 1. Define the containerView X Position
134 | [containerView applyLeadingAndTrailingPinConstraintToSuperview:space];
135 |
136 | NSInteger count = 20;
137 | UIButton *previousContentButton = nil;
138 |
139 | for (NSInteger i = 0; i < count; i++)
140 | {
141 | UIButton *contentButton = [UIButton prepareAutoLayoutView];
142 | if (i&1) {
143 | [contentButton setBackgroundColor:[UIColor Green]];
144 | }else{
145 | [contentButton setBackgroundColor:[UIColor Red]];
146 | }
147 |
148 | [contentButton setTag:i];
149 | [contentButton.layer setBorderWidth:1.5f];
150 | [contentButton.layer setBorderColor:[UIColor Indigo].CGColor];
151 | [containerView addSubview:contentButton];
152 |
153 | // Define the contentButton Size
154 | [contentButton applyTopAndBottomPinConstraintToSuperview:space];
155 |
156 | [contentButton applyAspectRatioConstraint];
157 | //OR
158 | // [contentButton applyWidthConstraint:60.0];
159 |
160 | if (i == 0) // for first
161 | {
162 | [contentButton applyLeadingPinConstraintToSuperview:space];
163 | }
164 | else if (i == count-1) // for last
165 | {
166 | [previousContentButton applyConstraintFromSiblingViewAttribute:NSLayoutAttributeTrailing toAttribute:NSLayoutAttributeLeading ofView:contentButton spacing:space];
167 |
168 | [contentButton applyTrailingPinConstraintToSuperview:space];
169 | }
170 | else
171 | {
172 | [previousContentButton applyConstraintFromSiblingViewAttribute:NSLayoutAttributeTrailing toAttribute:NSLayoutAttributeLeading ofView:contentButton spacing:space];
173 | }
174 |
175 | previousContentButton = contentButton;
176 | }
177 |
178 | [containerView updateModifyConstraints];
179 |
180 | }
181 |
182 |
183 | @end
184 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsMaster/NSLayoutConstraint+KVConstraintExtensions.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSLayoutConstraint+KVConstraintExtensions.m
3 | // https://github.com/keshavvishwkarma/KVConstraintExtensionsMaster.git
4 | //
5 | // Distributed under the MIT License.
6 | //
7 | // Copyright (c) 2015 Keshav Vishwkarma
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy of
10 | // this software and associated documentation files (the "Software"), to deal in
11 | // the Software without restriction, including without limitation the rights to
12 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13 | // of the Software, and to permit persons to whom the Software is furnished to do
14 | // so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in all
17 | // copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | // SOFTWARE.
26 | //
27 |
28 | #import "KVConstraintExtensionsMaster.h"
29 |
30 | #pragma mark - default constants values
31 |
32 | const CGFloat defaultMultiplier = 1.0f;
33 | const CGFloat defaultConstant = 0.0f;
34 | const NSLayoutRelation defaultRelation = NSLayoutRelationEqual;
35 | const CGFloat defaultLessMaxPriority = 999.99996 ;
36 | const CGFloat default_iPadRatio = 4.0/3.0;
37 |
38 | @implementation NSLayoutConstraint (KVConstraintExtensions)
39 |
40 | + (CGFloat)defaultSpacingBetweenSiblings
41 | {
42 | static NSLayoutConstraint *constraint;
43 | static dispatch_once_t onceToken;
44 | dispatch_once(&onceToken, ^{
45 | UIView *view = [UIView prepareAutoLayoutView];
46 | constraint = [NSLayoutConstraint constraintsWithVisualFormat:@"[view]-[view]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(view)].firstObject;
47 | });
48 |
49 | return constraint.constant; // 20.0 expected
50 | }
51 |
52 | + (CGFloat)defaultSpacingBetweenSuperview
53 | {
54 | static NSLayoutConstraint *constraint;
55 | static dispatch_once_t onceToken;
56 | dispatch_once(&onceToken, ^{
57 | UIView *view = [UIView prepareAutoLayoutView];
58 | UIView *Superview = [UIView prepareAutoLayoutView];
59 | [Superview addSubview:view];
60 | constraint = [NSLayoutConstraint constraintsWithVisualFormat:@"|-[view]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(view)].firstObject;
61 | });
62 |
63 | return constraint.constant; // 20.0 expected
64 | }
65 |
66 | + (BOOL)isSelfConstraintAttribute:(NSLayoutAttribute)attribute {
67 | if ((attribute == NSLayoutAttributeWidth)||(attribute == NSLayoutAttributeHeight)||(attribute == (NSLayoutAttributeWidth|NSLayoutAttributeHeight))) {
68 | return YES;
69 | }
70 | return NO;
71 | }
72 |
73 | + (BOOL)recognizedDirectionByAttribute:(NSLayoutAttribute)attribute toAttribute:(NSLayoutAttribute)toTttribute
74 | {
75 | if (((attribute == NSLayoutAttributeTrailing) && (toTttribute == NSLayoutAttributeTrailing))) {
76 | return YES; // is Negative Direction
77 | }else if (((attribute == NSLayoutAttributeTrailing) && (toTttribute == NSLayoutAttributeLeading))) {
78 | return YES; // is Negative Direction
79 | }else if (((attribute == NSLayoutAttributeTrailing) && (toTttribute == NSLayoutAttributeLeft))) {
80 | return YES; // is Negative Direction
81 | } else if (((attribute == NSLayoutAttributeRight) && (toTttribute == NSLayoutAttributeRight))) {
82 | return YES; // is Negative Direction
83 | }else if (((attribute == NSLayoutAttributeRight) && (toTttribute == NSLayoutAttributeLeft))) {
84 | return YES; // is Negative Direction
85 | } else if (((attribute == NSLayoutAttributeRight) && (toTttribute == NSLayoutAttributeLeading))) {
86 | return YES; // is Negative Direction
87 | } else if (((attribute == NSLayoutAttributeBottom) && (toTttribute == NSLayoutAttributeBottom))) {
88 | return YES; // is Negative Direction
89 | } else if (((attribute == NSLayoutAttributeBottom) && (toTttribute == NSLayoutAttributeTop))) {
90 | return YES; // is Negative Direction
91 | }
92 |
93 | return NO;
94 | }
95 |
96 | + (NSLayoutConstraint *)appliedConstraintForView:(UIView*)aView attribute:(NSLayoutAttribute)attribute {
97 | assert(aView!=nil);
98 |
99 | if ([self isSelfConstraintAttribute:attribute]) {
100 |
101 | KVLog(@"Tracing constrain in subview constraints, count = %@",@(aView.constraints.count));
102 | for (NSLayoutConstraint *actualConstraint in aView.constraints)
103 | {
104 | if ( (actualConstraint.firstItem == nil && actualConstraint.secondItem == aView)||
105 | (actualConstraint.firstItem == aView && actualConstraint.secondItem == nil) )
106 | {
107 | // In this case, this constraintint may be either widthConstraint or heightConstrain
108 | if (attribute == (actualConstraint.firstAttribute|actualConstraint.secondAttribute)) {
109 | return actualConstraint;
110 | }
111 | }
112 | else if ( (actualConstraint.firstItem == aView )&&(actualConstraint.secondItem == aView ))
113 | {
114 | // In this case, this constraintint is only aspectRatioConstrain
115 | if (attribute == (actualConstraint.firstAttribute|actualConstraint.secondAttribute)) {
116 | return actualConstraint;
117 | }
118 | } else {
119 | /* do some stuff for other work*/
120 | }
121 | }
122 | }
123 | else
124 | {
125 | KVLog(@"Tracing constrain in superview constraints, count = %@",@(aView.constraints.count));
126 |
127 | for (NSLayoutConstraint *actualConstraint in aView.superview.constraints)
128 | {
129 | if ( ((actualConstraint.firstItem == aView)&&(actualConstraint.secondItem == aView.superview))||
130 | ((actualConstraint.secondItem == aView )&&(actualConstraint.firstItem == aView.superview)) )
131 | {
132 | // In this case, this constraintint is only aspectRatioConstrain
133 | if ( (attribute == actualConstraint.firstAttribute)&&
134 | (attribute == actualConstraint.secondAttribute) ) {
135 | return actualConstraint;
136 | }
137 | else {
138 | /* do some stuff for other work*/
139 | }
140 | }
141 | }
142 | }
143 |
144 | return nil;
145 | }
146 |
147 | - (BOOL)isEqualToConstraint:(NSLayoutConstraint *)aConstraint
148 | {
149 | if (self.firstItem == aConstraint.firstItem &&
150 | self.firstAttribute == aConstraint.firstAttribute &&
151 | self.relation == aConstraint.relation &&
152 | self.secondItem == aConstraint.secondItem &&
153 | self.secondAttribute == aConstraint.secondAttribute &&
154 | self.multiplier == aConstraint.multiplier ) {
155 | return YES;
156 | }
157 |
158 | return NO;
159 | }
160 |
161 | - (NSLayoutConstraint *)swapConstraintItems
162 | {
163 | return [NSLayoutConstraint constraintWithItem:self.secondItem
164 | attribute:self.secondAttribute
165 | relatedBy:self.relation
166 | toItem:self.firstItem
167 | attribute:self.firstAttribute
168 | multiplier:self.multiplier
169 | constant:self.constant];
170 | }
171 |
172 | - (NSLayoutConstraint *)modifyConstraintRelatedBy:(NSLayoutRelation)relation
173 | {
174 | return [NSLayoutConstraint constraintWithItem:self.firstItem
175 | attribute:self.firstAttribute
176 | relatedBy:relation
177 | toItem:self.secondItem
178 | attribute:self.secondAttribute
179 | multiplier:self.multiplier
180 | constant:self.constant];
181 | }
182 |
183 | - (NSLayoutConstraint *)modifyConstraintMultiplierBy:(CGFloat)multiplier
184 | {
185 | return [NSLayoutConstraint constraintWithItem:self.firstItem
186 | attribute:self.firstAttribute
187 | relatedBy:self.relation
188 | toItem:self.secondItem
189 | attribute:self.secondAttribute
190 | multiplier:multiplier
191 | constant:self.constant];
192 | }
193 |
194 | @end
195 |
196 | @implementation NSArray (KV_ContainsConstraint)
197 |
198 | - (NSLayoutConstraint *)containsAppliedConstraint:(NSLayoutConstraint *)appliedConstraint{
199 | for (NSLayoutConstraint *actualConstraint in self) {
200 | if ([actualConstraint isEqualToConstraint:appliedConstraint])
201 | return actualConstraint;
202 | }
203 | return nil;
204 | }
205 |
206 | @end
--------------------------------------------------------------------------------
/KVConstraintExtensionsMaster/UIView+KVConstraintExtensions.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+KVConstraintExtensions.h
3 | // https://github.com/keshavvishwkarma/KVConstraintExtensionsMaster.git
4 | //
5 | // Distributed under the MIT License.
6 | //
7 | // Copyright (c) 2015 Keshav Vishwkarma
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy of
10 | // this software and associated documentation files (the "Software"), to deal in
11 | // the Software without restriction, including without limitation the rights to
12 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13 | // of the Software, and to permit persons to whom the Software is furnished to do
14 | // so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in all
17 | // copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | // SOFTWARE.
26 | //
27 |
28 | #import
29 |
30 | @interface UIView (KVConstraintExtensions)
31 |
32 | /**
33 | This method is used to create new instance of ui elements (view) for autolayout.
34 | */
35 | + (instancetype)prepareAutoLayoutView;
36 |
37 | /**
38 | This method is used to prepare already created instance of ui elements (view) for autolayout.
39 | */
40 | - (void)prepareAutoLayoutView;
41 |
42 | #pragma mark - Generic methods
43 | #pragma mark - To create constraints for superview
44 |
45 | - (NSLayoutConstraint *)prepareConstraintToSuperviewAttribute:(NSLayoutAttribute)attribute1 attribute:(NSLayoutAttribute)attribute2 relation:(NSLayoutRelation)relation;
46 |
47 | - (NSLayoutConstraint *)prepareEqualRelationPinConstraintToSuperview:(NSLayoutAttribute)attribute constant:(CGFloat)constant;
48 |
49 | - (NSLayoutConstraint *)prepareEqualRelationPinRatioConstraintToSuperview:(NSLayoutAttribute)attribute multiplier:(CGFloat)multiplier;
50 |
51 | #pragma mark - To create constraints for sibling views
52 |
53 | - (NSLayoutConstraint *)prepareConstraintFromSiblingViewAttribute:(NSLayoutAttribute)attribute toAttribute:(NSLayoutAttribute)toAttribute ofView:(UIView *)otherSiblingView relation:(NSLayoutRelation)relation;
54 |
55 | - (NSLayoutConstraint *)prepareConstraintFromSiblingViewAttribute:(NSLayoutAttribute)attribute toAttribute:(NSLayoutAttribute)toAttribute ofView:(UIView *)otherSiblingView multiplier:(CGFloat)multiplier;
56 |
57 | #pragma mark - Add constraints
58 |
59 | /*!
60 | This method is used to add constraint in receiver, if constraint is not already added other wise it will update constraint.
61 | */
62 | - (void)applyPreparedConstraintInView:(NSLayoutConstraint *)constraint;
63 |
64 | #pragma mark - Remove Constraints From a specific View
65 |
66 | /*!
67 | This method is used to remove all the its related constraint from the its superview & its sibling.
68 | */
69 | - (void)removedConstraintFromSupreview;
70 |
71 | /*!
72 | This method is used to remove all constraint (self + superview + sibling).
73 | */
74 | - (void)removedAllConstraints;
75 |
76 | #pragma mark - Modify applied constraint of a UIView
77 |
78 | /*!
79 | This method is used to change the priority of constraint.
80 | */
81 | - (void)changeAppliedConstraintPriority:(UILayoutPriority)priority forAttribute:(NSLayoutAttribute)attribute;
82 |
83 | /*!
84 | This method is used to replace already applied constraint by new constraint.
85 | */
86 | - (void)replaceAppliedConstraintInView:(NSLayoutConstraint *)appliedConstraint replaceBy:(NSLayoutConstraint *)constraint;
87 |
88 | /*!
89 | This method is internaly call layoutIfNeeded & setNeedsLayout.
90 | */
91 | - (void)updateModifyConstraints;
92 |
93 | /*!
94 | This method is used to update modified constraints with animation.
95 | */
96 | - (void)updateModifyConstraintsWithAnimation:(void (^)(BOOL finished))completion;
97 |
98 | /*!
99 | This method is used to update constraint constant value by ratio.
100 |
101 | @param attribute attribute to which constraint constant value needs to be updated.
102 | @param constantRatio constantRatio by which constant value will be updateed.
103 | */
104 |
105 | - (void)updateAppliedConstraintConstantValueByAttribute:(NSLayoutAttribute)attribute withConstantRatio:(CGFloat)constantRatio;
106 |
107 | /*!
108 | This method is used to update constraint constant value by default_iPadRatio only when it is running on iPad.
109 |
110 | @param attribute attribute to which constraint constant value needs to be updated.
111 | */
112 |
113 | - (void)updateAppliedConstraintConstantValueForIpadByAttribute:(NSLayoutAttribute)attribute;
114 |
115 | /*!
116 | This method is used to update constraint constant value by 1/default_iPadRatio only when it is running on iPhone.
117 |
118 | @param attribute attribute to which constraint constant value needs to be updated.
119 | */
120 | - (void)updateAppliedConstraintConstantValueForIphoneByAttribute:(NSLayoutAttribute)attribute;
121 |
122 | /*!
123 | This method is used to update font size by ratio.
124 | */
125 | - (void)scaleFontSizeByRatio:(CGFloat)ratio;
126 |
127 | #pragma mark - Access Applied Constraint By Attributes From a specific View
128 |
129 | /*!
130 | This method is used to access already applied constraint (means expected constraint) constraint by attribute of a constraints.
131 | */
132 | - (NSLayoutConstraint*)accessAppliedConstraintByAttribute:(NSLayoutAttribute)attribute;
133 |
134 | /*!
135 | This method is also used to access already applied constraint (means expected constraint) by attribute of a constraints with completion block.
136 | */
137 | - (void)accessAppliedConstraintByAttribute:(NSLayoutAttribute)attribute completion:(void (^)(NSLayoutConstraint *appliedConstraint))completion;
138 |
139 | /** This method is used to access already applied constraint apply\add constraint between two sibling views. No matter by which sibling View you call this method & no matter order of attributes but you need to call it by one sibling View and pass second other sibling View.
140 | */
141 | - (NSLayoutConstraint*)accessAppliedConstraintFromSiblingViewByAttribute:(NSLayoutAttribute)attribute toAttribute:(NSLayoutAttribute)toAttribute ofView:(UIView *)otherSiblingView;
142 |
143 | #pragma mark - Apply Pin Edges to Superview
144 |
145 | /*!
146 | * Theses method are used to apply\add Left, Right, Top, Bottom, Leading, Trailing, CenterX & CenterY pin constraints in it's superview (means in supreview of receiver (self). )
147 |
148 | @param padding padding constraint constant value
149 | */
150 |
151 | /*!
152 | To Apply\Add left pin constraint to superview of receiver.
153 | */
154 | - (void)applyLeftPinConstraintToSuperview:(CGFloat)padding;
155 |
156 | /*!
157 | To Apply\Add right pin constraint to superview of receiver.
158 | */
159 | - (void)applyRightPinConstraintToSuperview:(CGFloat)padding;
160 |
161 | /*!
162 | To Apply\Add leading pin constraint to superview of receiver.
163 | */
164 | - (void)applyLeadingPinConstraintToSuperview:(CGFloat)padding;
165 |
166 | /*!
167 | To Apply\Add triling pin constraint to superview of receiver.
168 | */
169 | - (void)applyTrailingPinConstraintToSuperview:(CGFloat)padding;
170 |
171 | /*!
172 | To Apply\Add top pin constraint to superview of receiver.
173 | */
174 | - (void)applyTopPinConstraintToSuperview:(CGFloat)padding;
175 |
176 | /*!
177 | To Apply\Add bottom pin constraint to superview of receiver.
178 | */
179 | - (void)applyBottomPinConstraintToSuperview:(CGFloat)padding;
180 |
181 | /*!
182 | To Apply\Add centerX pin constraint to superview of receiver.
183 | */
184 | - (void)applyCenterXPinConstraintToSuperview:(CGFloat)padding;
185 |
186 | /*!
187 | To Apply\Add centerY pin constraint to superview of receiver.
188 | */
189 | - (void)applyCenterYPinConstraintToSuperview:(CGFloat)padding;
190 |
191 | /*!
192 | * This method is used to apply\add same leading & trailing pin constraints to superview.
193 |
194 | @param padding padding constraint constant value
195 | */
196 | - (void)applyLeadingAndTrailingPinConstraintToSuperview:(CGFloat)padding;
197 |
198 | /*!
199 | * This method is used to apply\add same Top and Bottom pin constraints to superview.
200 |
201 | @param padding padding constraint constant value
202 | */
203 | - (void)applyTopAndBottomPinConstraintToSuperview:(CGFloat)padding;
204 |
205 | /*!
206 | * This method is used to apply\add equal width pin constraints to superview.
207 | */
208 | - (void)applyEqualWidthPinConstrainToSuperview;
209 |
210 | /*!
211 | * This method is used to apply\add equal height pin constraints to superview.
212 | */
213 | - (void)applyEqualHeightPinConstrainToSuperview;
214 |
215 | /*!
216 | * This method is used to apply\add equal width pin constraints to superview in %(percentage).
217 |
218 | @param ratio ratio constraint multiplier value
219 | */
220 | - (void)applyEqualHeightRatioPinConstrainToSuperview: (CGFloat)ratio;
221 |
222 | /*!
223 | * This method is used to apply\add equal height pin constraints to superview in %(percentage).
224 |
225 | @param ratio ratio constraint multiplier value
226 | */
227 | - (void)applyEqualWidthRatioPinConstrainToSuperview: (CGFloat)ratio;
228 |
229 | /*!
230 | * This method is used to apply\add CenterX pin constraint to receiver view at a specific X position in it's superview.
231 |
232 | @param ratio ratio constraint multiplier value
233 | @param padding padding constraint constant value
234 | */
235 |
236 | - (void)applyCenterXRatioPinConstrainToSuperview:(CGFloat)ratio padding:(CGFloat)padding;
237 |
238 | /*!
239 | * This method is used to apply\add CenterY pin constraint to center receiver view at a specific Y position in it's superview.
240 |
241 | @param ratio ratio constraint multiplier value
242 | @param padding padding constraint constant value
243 | */
244 | - (void)applyCenterYRatioPinConstrainToSuperview:(CGFloat)ratio padding:(CGFloat)padding;
245 |
246 | /*!
247 | * This method is used to apply\add CenterX & CenterY pin constraints to fully centered receiver view in it's superview.
248 | */
249 | - (void)applyConstraintForCenterInSuperview;
250 |
251 | /*!
252 | * This method is used to apply\add CenterY pin constraint to center vertically receiver view in it's superview.
253 | */
254 | - (void)applyConstraintForVerticallyCenterInSuperview;
255 |
256 | /*!
257 | * This method is used to apply\add CenterX pin constraint to center horizontally receiver view in it's superview.
258 | */
259 | - (void)applyConstraintForHorizontallyCenterInSuperview;
260 |
261 | /*!
262 | * This method is used to apply\add top, bottom, leading & trailing pin constraints to fully cover it's superview.
263 | */
264 | - (void)applyConstraintFitToSuperview;
265 |
266 | /*!
267 | * This method is used to apply\add leading & trailing pin constraints to fully cover it's superview horizontally.
268 | */
269 | - (void)applyConstraintFitToSuperviewHorizontally;
270 |
271 | /*!
272 | * This method is used to apply\add top & bottom pin constraints to fully cover it's superview vertically.
273 | */
274 | - (void)applyConstraintFitToSuperviewVertically;
275 |
276 | /*!
277 | * This method is used to apply\add top, left, bottom & right pin constraints to cover it's superview according to edge insets.
278 |
279 | * to exclude any pin constraint between (top, left, bottom & right) then set Inset Edge INFINITY/HUGE_VALF.
280 | * For Ex. we want to exclude then we must set left Edge of insets either INFINITY or HUGE_VALF.
281 | * [self applyConstraintFitToSuperviewContentInset:UIEdgeInsetsMake(0, INFINITY, 0, 0)];
282 |
283 | @param insets edge insets
284 | */
285 | - (void)applyConstraintFitToSuperviewContentInset:(UIEdgeInsets)Insets;
286 |
287 | #pragma mark - Apply self view constraints
288 |
289 | /*!
290 | To Apply\Add aspect ratio constraint in receiver view.
291 | */
292 | - (void)applyAspectRatioConstraint;
293 |
294 | /*!
295 | To Apply\Add width constraint in receiver view.
296 |
297 | @param width width constraint constant value
298 | */
299 | - (void)applyWidthConstraint:(CGFloat)width;
300 |
301 | /*!
302 | To Apply\Add height constraint in receiver view.
303 |
304 | @param height height constraint constant value
305 | */
306 |
307 | - (void)applyHeightConstraint:(CGFloat) height;
308 |
309 | /*!
310 | To Apply\Add width and height constraints in receiver view.
311 |
312 | @param size GGSize struct width and height values
313 | */
314 | - (void)applySizeConstraint:(CGSize)size;
315 |
316 | #pragma mark - Apply Constraint between sibling views
317 | /*!
318 | This method is used to apply\add constraint between sibling views.
319 | */
320 | - (void)applyConstraintFromSiblingViewAttribute:(NSLayoutAttribute)attribute toAttribute:(NSLayoutAttribute)toAttribute ofView:(UIView *)otherSiblingView spacing:(CGFloat)spacing;
321 |
322 | @end
323 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsMaster.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 6B2FFDF91C53CF7900BBFC20 /* KVConstraintExtensionsMaster.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B2FFDF81C53CF7900BBFC20 /* KVConstraintExtensionsMaster.h */; };
11 | 6B2FFE001C53CF7900BBFC20 /* KVConstraintExtensionsMaster.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B2FFDF51C53CF7900BBFC20 /* KVConstraintExtensionsMaster.framework */; };
12 | 6B2FFE051C53CF7900BBFC20 /* KVConstraintExtensionsMasterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B2FFE041C53CF7900BBFC20 /* KVConstraintExtensionsMasterTests.m */; };
13 | 6BC0AAB71C53F99E000F71C9 /* KVConstraintExtensionsMaster.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BC0AAB61C53F99E000F71C9 /* KVConstraintExtensionsMaster.h */; settings = {ATTRIBUTES = (Public, ); }; };
14 | 6BCB19B11C53D3D100D47ED1 /* NSLayoutConstraint+KVConstraintExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BCB19AB1C53D3D100D47ED1 /* NSLayoutConstraint+KVConstraintExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
15 | 6BCB19B21C53D3D100D47ED1 /* NSLayoutConstraint+KVConstraintExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BCB19AC1C53D3D100D47ED1 /* NSLayoutConstraint+KVConstraintExtensions.m */; };
16 | 6BCB19B31C53D3D100D47ED1 /* UIView+KVConstraintExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BCB19AD1C53D3D100D47ED1 /* UIView+KVConstraintExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
17 | 6BCB19B41C53D3D100D47ED1 /* UIView+KVConstraintExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BCB19AE1C53D3D100D47ED1 /* UIView+KVConstraintExtensions.m */; };
18 | 6BCB19B51C53D3D100D47ED1 /* UIViewController+KVConstraintExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BCB19AF1C53D3D100D47ED1 /* UIViewController+KVConstraintExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
19 | 6BCB19B61C53D3D100D47ED1 /* UIViewController+KVConstraintExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BCB19B01C53D3D100D47ED1 /* UIViewController+KVConstraintExtensions.m */; };
20 | /* End PBXBuildFile section */
21 |
22 | /* Begin PBXContainerItemProxy section */
23 | 6B2FFE011C53CF7900BBFC20 /* PBXContainerItemProxy */ = {
24 | isa = PBXContainerItemProxy;
25 | containerPortal = 6B2FFDEC1C53CF7900BBFC20 /* Project object */;
26 | proxyType = 1;
27 | remoteGlobalIDString = 6B2FFDF41C53CF7900BBFC20;
28 | remoteInfo = KVConstraintExtensionsMaster;
29 | };
30 | /* End PBXContainerItemProxy section */
31 |
32 | /* Begin PBXFileReference section */
33 | 6B2FFDF51C53CF7900BBFC20 /* KVConstraintExtensionsMaster.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = KVConstraintExtensionsMaster.framework; sourceTree = BUILT_PRODUCTS_DIR; };
34 | 6B2FFDF81C53CF7900BBFC20 /* KVConstraintExtensionsMaster.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KVConstraintExtensionsMaster.h; sourceTree = ""; };
35 | 6B2FFDFA1C53CF7900BBFC20 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
36 | 6B2FFDFF1C53CF7900BBFC20 /* KVConstraintExtensionsMasterTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = KVConstraintExtensionsMasterTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
37 | 6B2FFE041C53CF7900BBFC20 /* KVConstraintExtensionsMasterTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KVConstraintExtensionsMasterTests.m; sourceTree = ""; };
38 | 6B2FFE061C53CF7900BBFC20 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
39 | 6BC0AAB61C53F99E000F71C9 /* KVConstraintExtensionsMaster.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KVConstraintExtensionsMaster.h; sourceTree = ""; };
40 | 6BC0AAB81C53F9D9000F71C9 /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = ""; };
41 | 6BCB19AB1C53D3D100D47ED1 /* NSLayoutConstraint+KVConstraintExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSLayoutConstraint+KVConstraintExtensions.h"; sourceTree = ""; };
42 | 6BCB19AC1C53D3D100D47ED1 /* NSLayoutConstraint+KVConstraintExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSLayoutConstraint+KVConstraintExtensions.m"; sourceTree = ""; };
43 | 6BCB19AD1C53D3D100D47ED1 /* UIView+KVConstraintExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+KVConstraintExtensions.h"; sourceTree = ""; };
44 | 6BCB19AE1C53D3D100D47ED1 /* UIView+KVConstraintExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+KVConstraintExtensions.m"; sourceTree = ""; };
45 | 6BCB19AF1C53D3D100D47ED1 /* UIViewController+KVConstraintExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+KVConstraintExtensions.h"; sourceTree = ""; };
46 | 6BCB19B01C53D3D100D47ED1 /* UIViewController+KVConstraintExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+KVConstraintExtensions.m"; sourceTree = ""; };
47 | /* End PBXFileReference section */
48 |
49 | /* Begin PBXFrameworksBuildPhase section */
50 | 6B2FFDF11C53CF7900BBFC20 /* Frameworks */ = {
51 | isa = PBXFrameworksBuildPhase;
52 | buildActionMask = 2147483647;
53 | files = (
54 | );
55 | runOnlyForDeploymentPostprocessing = 0;
56 | };
57 | 6B2FFDFC1C53CF7900BBFC20 /* Frameworks */ = {
58 | isa = PBXFrameworksBuildPhase;
59 | buildActionMask = 2147483647;
60 | files = (
61 | 6B2FFE001C53CF7900BBFC20 /* KVConstraintExtensionsMaster.framework in Frameworks */,
62 | );
63 | runOnlyForDeploymentPostprocessing = 0;
64 | };
65 | /* End PBXFrameworksBuildPhase section */
66 |
67 | /* Begin PBXGroup section */
68 | 6B2FFDEB1C53CF7900BBFC20 = {
69 | isa = PBXGroup;
70 | children = (
71 | 6B2FFDF71C53CF7900BBFC20 /* KVConstraintExtensionsMaster */,
72 | 6B2FFE031C53CF7900BBFC20 /* KVConstraintExtensionsMasterTests */,
73 | 6B2FFDF61C53CF7900BBFC20 /* Products */,
74 | );
75 | sourceTree = "";
76 | };
77 | 6B2FFDF61C53CF7900BBFC20 /* Products */ = {
78 | isa = PBXGroup;
79 | children = (
80 | 6B2FFDF51C53CF7900BBFC20 /* KVConstraintExtensionsMaster.framework */,
81 | 6B2FFDFF1C53CF7900BBFC20 /* KVConstraintExtensionsMasterTests.xctest */,
82 | );
83 | name = Products;
84 | sourceTree = "";
85 | };
86 | 6B2FFDF71C53CF7900BBFC20 /* KVConstraintExtensionsMaster */ = {
87 | isa = PBXGroup;
88 | children = (
89 | 6B2FFDF81C53CF7900BBFC20 /* KVConstraintExtensionsMaster.h */,
90 | 6BCB19AB1C53D3D100D47ED1 /* NSLayoutConstraint+KVConstraintExtensions.h */,
91 | 6BCB19AC1C53D3D100D47ED1 /* NSLayoutConstraint+KVConstraintExtensions.m */,
92 | 6BCB19AD1C53D3D100D47ED1 /* UIView+KVConstraintExtensions.h */,
93 | 6BCB19AE1C53D3D100D47ED1 /* UIView+KVConstraintExtensions.m */,
94 | 6BCB19AF1C53D3D100D47ED1 /* UIViewController+KVConstraintExtensions.h */,
95 | 6BCB19B01C53D3D100D47ED1 /* UIViewController+KVConstraintExtensions.m */,
96 | 6BCB19AA1C53D35700D47ED1 /* Supporting Files */,
97 | );
98 | path = KVConstraintExtensionsMaster;
99 | sourceTree = "";
100 | };
101 | 6B2FFE031C53CF7900BBFC20 /* KVConstraintExtensionsMasterTests */ = {
102 | isa = PBXGroup;
103 | children = (
104 | 6B2FFE041C53CF7900BBFC20 /* KVConstraintExtensionsMasterTests.m */,
105 | 6B2FFE061C53CF7900BBFC20 /* Info.plist */,
106 | );
107 | path = KVConstraintExtensionsMasterTests;
108 | sourceTree = "";
109 | };
110 | 6BCB19AA1C53D35700D47ED1 /* Supporting Files */ = {
111 | isa = PBXGroup;
112 | children = (
113 | 6BC0AAB61C53F99E000F71C9 /* KVConstraintExtensionsMaster.h */,
114 | 6BC0AAB81C53F9D9000F71C9 /* module.modulemap */,
115 | 6B2FFDFA1C53CF7900BBFC20 /* Info.plist */,
116 | );
117 | name = "Supporting Files";
118 | path = "../Supporting Files";
119 | sourceTree = "";
120 | };
121 | /* End PBXGroup section */
122 |
123 | /* Begin PBXHeadersBuildPhase section */
124 | 6B2FFDF21C53CF7900BBFC20 /* Headers */ = {
125 | isa = PBXHeadersBuildPhase;
126 | buildActionMask = 2147483647;
127 | files = (
128 | 6BC0AAB71C53F99E000F71C9 /* KVConstraintExtensionsMaster.h in Headers */,
129 | 6BCB19B31C53D3D100D47ED1 /* UIView+KVConstraintExtensions.h in Headers */,
130 | 6BCB19B51C53D3D100D47ED1 /* UIViewController+KVConstraintExtensions.h in Headers */,
131 | 6BCB19B11C53D3D100D47ED1 /* NSLayoutConstraint+KVConstraintExtensions.h in Headers */,
132 | 6B2FFDF91C53CF7900BBFC20 /* KVConstraintExtensionsMaster.h in Headers */,
133 | );
134 | runOnlyForDeploymentPostprocessing = 0;
135 | };
136 | /* End PBXHeadersBuildPhase section */
137 |
138 | /* Begin PBXNativeTarget section */
139 | 6B2FFDF41C53CF7900BBFC20 /* KVConstraintExtensionsMaster */ = {
140 | isa = PBXNativeTarget;
141 | buildConfigurationList = 6B2FFE091C53CF7900BBFC20 /* Build configuration list for PBXNativeTarget "KVConstraintExtensionsMaster" */;
142 | buildPhases = (
143 | 6B2FFDF01C53CF7900BBFC20 /* Sources */,
144 | 6B2FFDF11C53CF7900BBFC20 /* Frameworks */,
145 | 6B2FFDF21C53CF7900BBFC20 /* Headers */,
146 | 6B2FFDF31C53CF7900BBFC20 /* Resources */,
147 | );
148 | buildRules = (
149 | );
150 | dependencies = (
151 | );
152 | name = KVConstraintExtensionsMaster;
153 | productName = KVConstraintExtensionsMaster;
154 | productReference = 6B2FFDF51C53CF7900BBFC20 /* KVConstraintExtensionsMaster.framework */;
155 | productType = "com.apple.product-type.framework";
156 | };
157 | 6B2FFDFE1C53CF7900BBFC20 /* KVConstraintExtensionsMasterTests */ = {
158 | isa = PBXNativeTarget;
159 | buildConfigurationList = 6B2FFE0C1C53CF7900BBFC20 /* Build configuration list for PBXNativeTarget "KVConstraintExtensionsMasterTests" */;
160 | buildPhases = (
161 | 6B2FFDFB1C53CF7900BBFC20 /* Sources */,
162 | 6B2FFDFC1C53CF7900BBFC20 /* Frameworks */,
163 | 6B2FFDFD1C53CF7900BBFC20 /* Resources */,
164 | );
165 | buildRules = (
166 | );
167 | dependencies = (
168 | 6B2FFE021C53CF7900BBFC20 /* PBXTargetDependency */,
169 | );
170 | name = KVConstraintExtensionsMasterTests;
171 | productName = KVConstraintExtensionsMasterTests;
172 | productReference = 6B2FFDFF1C53CF7900BBFC20 /* KVConstraintExtensionsMasterTests.xctest */;
173 | productType = "com.apple.product-type.bundle.unit-test";
174 | };
175 | /* End PBXNativeTarget section */
176 |
177 | /* Begin PBXProject section */
178 | 6B2FFDEC1C53CF7900BBFC20 /* Project object */ = {
179 | isa = PBXProject;
180 | attributes = {
181 | LastUpgradeCheck = 0720;
182 | ORGANIZATIONNAME = Keshav;
183 | TargetAttributes = {
184 | 6B2FFDF41C53CF7900BBFC20 = {
185 | CreatedOnToolsVersion = 7.2;
186 | };
187 | 6B2FFDFE1C53CF7900BBFC20 = {
188 | CreatedOnToolsVersion = 7.2;
189 | };
190 | };
191 | };
192 | buildConfigurationList = 6B2FFDEF1C53CF7900BBFC20 /* Build configuration list for PBXProject "KVConstraintExtensionsMaster" */;
193 | compatibilityVersion = "Xcode 3.2";
194 | developmentRegion = English;
195 | hasScannedForEncodings = 0;
196 | knownRegions = (
197 | en,
198 | );
199 | mainGroup = 6B2FFDEB1C53CF7900BBFC20;
200 | productRefGroup = 6B2FFDF61C53CF7900BBFC20 /* Products */;
201 | projectDirPath = "";
202 | projectRoot = "";
203 | targets = (
204 | 6B2FFDF41C53CF7900BBFC20 /* KVConstraintExtensionsMaster */,
205 | 6B2FFDFE1C53CF7900BBFC20 /* KVConstraintExtensionsMasterTests */,
206 | );
207 | };
208 | /* End PBXProject section */
209 |
210 | /* Begin PBXResourcesBuildPhase section */
211 | 6B2FFDF31C53CF7900BBFC20 /* Resources */ = {
212 | isa = PBXResourcesBuildPhase;
213 | buildActionMask = 2147483647;
214 | files = (
215 | );
216 | runOnlyForDeploymentPostprocessing = 0;
217 | };
218 | 6B2FFDFD1C53CF7900BBFC20 /* Resources */ = {
219 | isa = PBXResourcesBuildPhase;
220 | buildActionMask = 2147483647;
221 | files = (
222 | );
223 | runOnlyForDeploymentPostprocessing = 0;
224 | };
225 | /* End PBXResourcesBuildPhase section */
226 |
227 | /* Begin PBXSourcesBuildPhase section */
228 | 6B2FFDF01C53CF7900BBFC20 /* Sources */ = {
229 | isa = PBXSourcesBuildPhase;
230 | buildActionMask = 2147483647;
231 | files = (
232 | 6BCB19B61C53D3D100D47ED1 /* UIViewController+KVConstraintExtensions.m in Sources */,
233 | 6BCB19B41C53D3D100D47ED1 /* UIView+KVConstraintExtensions.m in Sources */,
234 | 6BCB19B21C53D3D100D47ED1 /* NSLayoutConstraint+KVConstraintExtensions.m in Sources */,
235 | );
236 | runOnlyForDeploymentPostprocessing = 0;
237 | };
238 | 6B2FFDFB1C53CF7900BBFC20 /* Sources */ = {
239 | isa = PBXSourcesBuildPhase;
240 | buildActionMask = 2147483647;
241 | files = (
242 | 6B2FFE051C53CF7900BBFC20 /* KVConstraintExtensionsMasterTests.m in Sources */,
243 | );
244 | runOnlyForDeploymentPostprocessing = 0;
245 | };
246 | /* End PBXSourcesBuildPhase section */
247 |
248 | /* Begin PBXTargetDependency section */
249 | 6B2FFE021C53CF7900BBFC20 /* PBXTargetDependency */ = {
250 | isa = PBXTargetDependency;
251 | target = 6B2FFDF41C53CF7900BBFC20 /* KVConstraintExtensionsMaster */;
252 | targetProxy = 6B2FFE011C53CF7900BBFC20 /* PBXContainerItemProxy */;
253 | };
254 | /* End PBXTargetDependency section */
255 |
256 | /* Begin XCBuildConfiguration section */
257 | 6B2FFE071C53CF7900BBFC20 /* Debug */ = {
258 | isa = XCBuildConfiguration;
259 | buildSettings = {
260 | ALWAYS_SEARCH_USER_PATHS = NO;
261 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
262 | CLANG_CXX_LIBRARY = "libc++";
263 | CLANG_ENABLE_MODULES = YES;
264 | CLANG_ENABLE_OBJC_ARC = YES;
265 | CLANG_WARN_BOOL_CONVERSION = YES;
266 | CLANG_WARN_CONSTANT_CONVERSION = YES;
267 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
268 | CLANG_WARN_EMPTY_BODY = YES;
269 | CLANG_WARN_ENUM_CONVERSION = YES;
270 | CLANG_WARN_INT_CONVERSION = YES;
271 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
272 | CLANG_WARN_UNREACHABLE_CODE = YES;
273 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
274 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
275 | COPY_PHASE_STRIP = NO;
276 | CURRENT_PROJECT_VERSION = 1;
277 | DEBUG_INFORMATION_FORMAT = dwarf;
278 | ENABLE_STRICT_OBJC_MSGSEND = YES;
279 | ENABLE_TESTABILITY = YES;
280 | GCC_C_LANGUAGE_STANDARD = gnu99;
281 | GCC_DYNAMIC_NO_PIC = NO;
282 | GCC_NO_COMMON_BLOCKS = YES;
283 | GCC_OPTIMIZATION_LEVEL = 0;
284 | GCC_PREPROCESSOR_DEFINITIONS = (
285 | "DEBUG=1",
286 | "$(inherited)",
287 | );
288 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
289 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
290 | GCC_WARN_UNDECLARED_SELECTOR = YES;
291 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
292 | GCC_WARN_UNUSED_FUNCTION = YES;
293 | GCC_WARN_UNUSED_VARIABLE = YES;
294 | IPHONEOS_DEPLOYMENT_TARGET = 9.2;
295 | MTL_ENABLE_DEBUG_INFO = YES;
296 | ONLY_ACTIVE_ARCH = YES;
297 | SDKROOT = iphoneos;
298 | TARGETED_DEVICE_FAMILY = "1,2";
299 | VERSIONING_SYSTEM = "apple-generic";
300 | VERSION_INFO_PREFIX = "";
301 | };
302 | name = Debug;
303 | };
304 | 6B2FFE081C53CF7900BBFC20 /* Release */ = {
305 | isa = XCBuildConfiguration;
306 | buildSettings = {
307 | ALWAYS_SEARCH_USER_PATHS = NO;
308 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
309 | CLANG_CXX_LIBRARY = "libc++";
310 | CLANG_ENABLE_MODULES = YES;
311 | CLANG_ENABLE_OBJC_ARC = YES;
312 | CLANG_WARN_BOOL_CONVERSION = YES;
313 | CLANG_WARN_CONSTANT_CONVERSION = YES;
314 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
315 | CLANG_WARN_EMPTY_BODY = YES;
316 | CLANG_WARN_ENUM_CONVERSION = YES;
317 | CLANG_WARN_INT_CONVERSION = YES;
318 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
319 | CLANG_WARN_UNREACHABLE_CODE = YES;
320 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
321 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
322 | COPY_PHASE_STRIP = NO;
323 | CURRENT_PROJECT_VERSION = 1;
324 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
325 | ENABLE_NS_ASSERTIONS = NO;
326 | ENABLE_STRICT_OBJC_MSGSEND = YES;
327 | GCC_C_LANGUAGE_STANDARD = gnu99;
328 | GCC_NO_COMMON_BLOCKS = YES;
329 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
330 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
331 | GCC_WARN_UNDECLARED_SELECTOR = YES;
332 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
333 | GCC_WARN_UNUSED_FUNCTION = YES;
334 | GCC_WARN_UNUSED_VARIABLE = YES;
335 | IPHONEOS_DEPLOYMENT_TARGET = 9.2;
336 | MTL_ENABLE_DEBUG_INFO = NO;
337 | SDKROOT = iphoneos;
338 | TARGETED_DEVICE_FAMILY = "1,2";
339 | VALIDATE_PRODUCT = YES;
340 | VERSIONING_SYSTEM = "apple-generic";
341 | VERSION_INFO_PREFIX = "";
342 | };
343 | name = Release;
344 | };
345 | 6B2FFE0A1C53CF7900BBFC20 /* Debug */ = {
346 | isa = XCBuildConfiguration;
347 | buildSettings = {
348 | DEFINES_MODULE = YES;
349 | DYLIB_COMPATIBILITY_VERSION = 1;
350 | DYLIB_CURRENT_VERSION = 1;
351 | DYLIB_INSTALL_NAME_BASE = "@rpath";
352 | INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist";
353 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
354 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
355 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
356 | PRODUCT_BUNDLE_IDENTIFIER = "Keshav-Vishwkarma.KVConstraintExtensionsMaster";
357 | PRODUCT_NAME = "$(TARGET_NAME)";
358 | SKIP_INSTALL = YES;
359 | };
360 | name = Debug;
361 | };
362 | 6B2FFE0B1C53CF7900BBFC20 /* Release */ = {
363 | isa = XCBuildConfiguration;
364 | buildSettings = {
365 | DEFINES_MODULE = YES;
366 | DYLIB_COMPATIBILITY_VERSION = 1;
367 | DYLIB_CURRENT_VERSION = 1;
368 | DYLIB_INSTALL_NAME_BASE = "@rpath";
369 | INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist";
370 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
371 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
372 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
373 | PRODUCT_BUNDLE_IDENTIFIER = "Keshav-Vishwkarma.KVConstraintExtensionsMaster";
374 | PRODUCT_NAME = "$(TARGET_NAME)";
375 | SKIP_INSTALL = YES;
376 | };
377 | name = Release;
378 | };
379 | 6B2FFE0D1C53CF7900BBFC20 /* Debug */ = {
380 | isa = XCBuildConfiguration;
381 | buildSettings = {
382 | INFOPLIST_FILE = KVConstraintExtensionsMasterTests/Info.plist;
383 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
384 | PRODUCT_BUNDLE_IDENTIFIER = "Keshav-Vishwkarma.KVConstraintExtensionsMasterTests";
385 | PRODUCT_NAME = "$(TARGET_NAME)";
386 | };
387 | name = Debug;
388 | };
389 | 6B2FFE0E1C53CF7900BBFC20 /* Release */ = {
390 | isa = XCBuildConfiguration;
391 | buildSettings = {
392 | INFOPLIST_FILE = KVConstraintExtensionsMasterTests/Info.plist;
393 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
394 | PRODUCT_BUNDLE_IDENTIFIER = "Keshav-Vishwkarma.KVConstraintExtensionsMasterTests";
395 | PRODUCT_NAME = "$(TARGET_NAME)";
396 | };
397 | name = Release;
398 | };
399 | /* End XCBuildConfiguration section */
400 |
401 | /* Begin XCConfigurationList section */
402 | 6B2FFDEF1C53CF7900BBFC20 /* Build configuration list for PBXProject "KVConstraintExtensionsMaster" */ = {
403 | isa = XCConfigurationList;
404 | buildConfigurations = (
405 | 6B2FFE071C53CF7900BBFC20 /* Debug */,
406 | 6B2FFE081C53CF7900BBFC20 /* Release */,
407 | );
408 | defaultConfigurationIsVisible = 0;
409 | defaultConfigurationName = Release;
410 | };
411 | 6B2FFE091C53CF7900BBFC20 /* Build configuration list for PBXNativeTarget "KVConstraintExtensionsMaster" */ = {
412 | isa = XCConfigurationList;
413 | buildConfigurations = (
414 | 6B2FFE0A1C53CF7900BBFC20 /* Debug */,
415 | 6B2FFE0B1C53CF7900BBFC20 /* Release */,
416 | );
417 | defaultConfigurationIsVisible = 0;
418 | defaultConfigurationName = Release;
419 | };
420 | 6B2FFE0C1C53CF7900BBFC20 /* Build configuration list for PBXNativeTarget "KVConstraintExtensionsMasterTests" */ = {
421 | isa = XCConfigurationList;
422 | buildConfigurations = (
423 | 6B2FFE0D1C53CF7900BBFC20 /* Debug */,
424 | 6B2FFE0E1C53CF7900BBFC20 /* Release */,
425 | );
426 | defaultConfigurationIsVisible = 0;
427 | defaultConfigurationName = Release;
428 | };
429 | /* End XCConfigurationList section */
430 | };
431 | rootObject = 6B2FFDEC1C53CF7900BBFC20 /* Project object */;
432 | }
433 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsMaster/UIView+KVConstraintExtensions.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+KVConstraintExtensions.m
3 | // https://github.com/keshavvishwkarma/KVConstraintExtensionsMaster.git
4 | //
5 | // Distributed under the MIT License.
6 | //
7 | // Copyright (c) 2015 Keshav Vishwkarma
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy of
10 | // this software and associated documentation files (the "Software"), to deal in
11 | // the Software without restriction, including without limitation the rights to
12 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13 | // of the Software, and to permit persons to whom the Software is furnished to do
14 | // so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in all
17 | // copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | // SOFTWARE.
26 | //
27 |
28 | #import "KVConstraintExtensionsMaster.h"
29 |
30 | @implementation UIView (KVConstraintExtensions)
31 |
32 | #pragma mark - Initializer Methods
33 |
34 | + (instancetype)prepareAutoLayoutView {
35 | UIView *preparedView = [self new];
36 | [preparedView prepareAutoLayoutView];
37 | return preparedView;
38 | }
39 |
40 | - (void)prepareAutoLayoutView {
41 | if (self.translatesAutoresizingMaskIntoConstraints) {
42 | self.translatesAutoresizingMaskIntoConstraints = NO;
43 | }
44 | }
45 |
46 | #pragma mark - private constraint methods for views
47 |
48 | + (NSLayoutConstraint *)prepareConstraintForView:(UIView*)firstView attribute:(NSLayoutAttribute)attribute1 secondView:(UIView*)secondView attribute:(NSLayoutAttribute)attribute2 relation:(NSLayoutRelation)relation multiplier:(CGFloat)multiplier
49 | {
50 | NSAssert((firstView||secondView), @"both firstView & secondView must not be nil.");
51 | NSAssert(multiplier!=INFINITY, @"Multiplier/Ratio of view must not be INFINITY.");
52 |
53 | return [NSLayoutConstraint constraintWithItem:firstView attribute:attribute1 relatedBy:relation toItem:secondView attribute:attribute2 multiplier:multiplier constant:defaultConstant];
54 | }
55 |
56 | - (NSLayoutConstraint *)prepareSelfConstraint:(NSLayoutAttribute)attribute constant:(CGFloat)constant
57 | {
58 | NSLayoutConstraint *prepareSelfConstraint = [self.class prepareConstraintForView:self attribute:attribute secondView:nil attribute:NSLayoutAttributeNotAnAttribute relation:defaultRelation multiplier:defaultMultiplier];
59 | [prepareSelfConstraint setConstant:constant];
60 | return prepareSelfConstraint;
61 | }
62 |
63 | #pragma mark - Generalized public constraint methods for views
64 |
65 | - (NSLayoutConstraint *)prepareConstraintToSuperviewAttribute:(NSLayoutAttribute)attribute1 attribute:(NSLayoutAttribute)attribute2 relation:(NSLayoutRelation)relation
66 | {
67 | return [self.class prepareConstraintForView:self attribute:attribute1 secondView:[self superview] attribute:attribute2 relation:relation multiplier:defaultMultiplier];
68 | }
69 |
70 | - (NSLayoutConstraint *)prepareEqualRelationPinConstraintToSuperview:(NSLayoutAttribute)attribute constant:(CGFloat)constant
71 | {
72 | NSLayoutConstraint *preparePinConstraint = [self prepareConstraintToSuperviewAttribute:attribute attribute:attribute relation:defaultRelation];
73 | [preparePinConstraint setConstant:constant];
74 | return preparePinConstraint;
75 | }
76 |
77 | - (NSLayoutConstraint *)prepareEqualRelationPinRatioConstraintToSuperview:(NSLayoutAttribute)attribute multiplier:(CGFloat)multiplier
78 | {
79 | NSAssert(multiplier!=INFINITY, @"Multiplier/Ratio of view must not be INFINITY.");
80 |
81 | // note if ratio is equal to zero then its ratio prefered 1.0 that is defaultMultiplier
82 | NSLayoutConstraint *preparedPinRatioConstraint = [self.class prepareConstraintForView:self attribute:attribute secondView:[self superview] attribute:attribute relation:defaultRelation multiplier:multiplier?multiplier:defaultMultiplier];
83 | return preparedPinRatioConstraint;
84 | }
85 |
86 | #pragma mark - Prepare constraint of one sibling view to other sibling view and add it into its superview view.
87 |
88 | - (NSLayoutConstraint *)prepareConstraintFromSiblingViewAttribute:(NSLayoutAttribute)attribute toAttribute:(NSLayoutAttribute)toAttribute ofView:(UIView *)otherSiblingView relation:(NSLayoutRelation)relation {
89 | // NSSet * set = [NSSet setWithArray:@[self.superview,otherSiblingView.superview]];
90 | NSAssert(([NSSet setWithArray:@[self.superview,otherSiblingView.superview]].count == 1), @"All the sibling views must belong to same superview");
91 |
92 | return [self.class prepareConstraintForView:self attribute:attribute secondView:otherSiblingView attribute:toAttribute relation:relation multiplier:defaultMultiplier];
93 | }
94 |
95 | - (NSLayoutConstraint *)prepareConstraintFromSiblingViewAttribute:(NSLayoutAttribute)attribute toAttribute:(NSLayoutAttribute)toAttribute ofView:(UIView *)otherSiblingView multiplier:(CGFloat)multiplier {
96 | NSAssert(multiplier!=INFINITY, @"ratio of spacing between sybings view must not be INFINITY.");
97 | // NSSet * set = [NSSet setWithArray:@[self.superview,otherSiblingView.superview]];
98 | NSAssert(([NSSet setWithArray:@[self.superview,otherSiblingView.superview]].count == 1), @"All the sibling views must belong to same superview");
99 |
100 | return [self.class prepareConstraintForView:self attribute:attribute secondView:otherSiblingView attribute:toAttribute relation:defaultRelation multiplier:multiplier];
101 | }
102 |
103 | #pragma mark - Add constraints cumulative
104 |
105 | /** This is the common methods two add cumulative constraint in a view
106 | * for this you need to call it according to view (self or Superview)
107 | */
108 | - (void)applyPreparedConstraintInView:(NSLayoutConstraint *)constraint {
109 | NSLayoutConstraint *appliedConstraint = [self.constraints containsAppliedConstraint:constraint];
110 | // if this constraint is already added then it update the constraint values else added new constraint
111 | if (appliedConstraint) {
112 | [appliedConstraint setConstant:constraint.constant];
113 | } else {
114 | if (constraint) {
115 | [self addConstraint:constraint];
116 | }
117 | }
118 | }
119 |
120 | #pragma mark - Remove Constraints From a specific View
121 |
122 | - (void)removedConstraintFromSupreview {
123 | UIView *superview = self.superview;
124 | [self removeFromSuperview];
125 | [superview addSubview:self];
126 | }
127 |
128 | - (void)removedAllConstraints {
129 | [self removedConstraintFromSupreview];
130 | if (self.constraints.count) {
131 | [self removeConstraints:self.constraints];
132 | }
133 | }
134 |
135 | #pragma mark - Modify constraint of a UIView
136 |
137 | - (void)changeAppliedConstraintPriority:(UILayoutPriority)priority forAttribute:(NSLayoutAttribute)attribute {
138 | [[self accessAppliedConstraintByAttribute:attribute] setPriority:priority];
139 | }
140 |
141 | - (void)replaceAppliedConstraintInView:(NSLayoutConstraint *)appliedConstraint replaceBy:(NSLayoutConstraint *)constraint {
142 | NSAssert(constraint!=nil, @" modifiedConstraint must not be nil");
143 |
144 | if ([appliedConstraint isEqualToConstraint:constraint]){
145 | [self removeConstraint:appliedConstraint];
146 | [self addConstraint:constraint];
147 | }else{
148 | KVLog(@"appliedConstraint does not contain caller view = %@ \n appliedConstraint = %@",self,appliedConstraint);
149 | }
150 | }
151 |
152 | - (void)updateModifyConstraints {
153 | [self layoutIfNeeded];
154 | [self setNeedsLayout];
155 | }
156 |
157 | - (void)updateModifyConstraintsWithAnimation:(void (^)(BOOL finished))completion {
158 | UIView *referenceView = self.superview ? self.superview : self;
159 | [UIView animateWithDuration:UINavigationControllerHideShowBarDuration animations:^{
160 | [referenceView updateModifyConstraints];
161 | } completion:completion];
162 | }
163 |
164 | - (void)updateAppliedConstraintConstantValueForIpadByAttribute:(NSLayoutAttribute)attribute{
165 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
166 | [self updateAppliedConstraintConstantValueByAttribute:attribute withConstantRatio:default_iPadRatio];
167 | }
168 | }
169 |
170 | - (void)updateAppliedConstraintConstantValueForIphoneByAttribute:(NSLayoutAttribute)attribute{
171 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
172 | [self updateAppliedConstraintConstantValueByAttribute:attribute withConstantRatio:1.0/default_iPadRatio];
173 | }
174 | }
175 |
176 | - (void)updateAppliedConstraintConstantValueByAttribute:(NSLayoutAttribute)attribute withConstantRatio:(CGFloat)constantRatio{
177 | [self accessAppliedConstraintByAttribute:attribute].constant *= constantRatio;
178 | }
179 |
180 | #pragma mark - Access Applied Constraint By Attributes From a specific View
181 |
182 | - (NSLayoutConstraint*)accessAppliedConstraintByAttribute:(NSLayoutAttribute)attribute {
183 | return [NSLayoutConstraint appliedConstraintForView:self attribute:attribute];
184 | }
185 |
186 | - (NSLayoutConstraint*)accessAppliedConstraintFromSiblingViewByAttribute:(NSLayoutAttribute)attribute toAttribute:(NSLayoutAttribute)toAttribute ofView:(UIView *)otherSiblingView {
187 |
188 | NSAssert(self!=otherSiblingView, @"both view must be sibling not same.");
189 |
190 | NSLayoutConstraint *appliedConstraint = nil;
191 |
192 | BOOL isSelfConstraintAttributes = (([NSLayoutConstraint isSelfConstraintAttribute:attribute])||([NSLayoutConstraint isSelfConstraintAttribute:toAttribute]));
193 | if (isSelfConstraintAttributes && ( attribute != toAttribute )) {
194 | KVLog(@"You should have provided valid sibling atributes of constraints.");
195 | }
196 | else
197 | {
198 | NSLayoutConstraint *prepareConstraintForSiblingView = [self prepareConstraintFromSiblingViewAttribute:attribute toAttribute:toAttribute ofView:otherSiblingView multiplier:defaultMultiplier];
199 |
200 | appliedConstraint = [self.superview.constraints containsAppliedConstraint:prepareConstraintForSiblingView];
201 |
202 | if (!appliedConstraint) {
203 | appliedConstraint = [self.superview.constraints containsAppliedConstraint:[prepareConstraintForSiblingView swapConstraintItems]];
204 | }
205 | }
206 |
207 | return appliedConstraint;
208 | }
209 |
210 |
211 | - (void)accessAppliedConstraintByAttribute:(NSLayoutAttribute)attribute completion:(void (^)(NSLayoutConstraint *appliedConstraint))completion
212 | {
213 | if (completion) {
214 | dispatch_async(dispatch_get_main_queue(), ^{
215 | completion([self accessAppliedConstraintByAttribute:attribute]);
216 | });
217 | }
218 | }
219 |
220 | #pragma mark - Pin Edges to Superview
221 | // adding or updating the constraint
222 | - (void)applyPreparedEqualRelationPinConstraintToSuperview:(NSLayoutAttribute)attribute constant:(CGFloat)constant {
223 | NSAssert(self.superview, @"You should have addSubView %@ on any other its called's Superview ", self);
224 | NSAssert(constant!=INFINITY, @"Constant must not be INFINITY.");
225 | [self.superview applyPreparedConstraintInView:[self prepareEqualRelationPinConstraintToSuperview:attribute constant:constant]];
226 | }
227 |
228 | - (void)applyLeftPinConstraintToSuperview:(CGFloat)padding {
229 | [self applyPreparedEqualRelationPinConstraintToSuperview:NSLayoutAttributeLeft constant:padding];
230 | }
231 | - (void)applyRightPinConstraintToSuperview:(CGFloat)padding {
232 | [self applyPreparedEqualRelationPinConstraintToSuperview:NSLayoutAttributeRight constant:-padding];
233 | }
234 | - (void)applyTopPinConstraintToSuperview:(CGFloat)padding {
235 | [self applyPreparedEqualRelationPinConstraintToSuperview:NSLayoutAttributeTop constant:padding];
236 | }
237 | - (void)applyBottomPinConstraintToSuperview:(CGFloat)padding {
238 | [self applyPreparedEqualRelationPinConstraintToSuperview:NSLayoutAttributeBottom constant:-padding];
239 | }
240 | - (void)applyLeadingPinConstraintToSuperview:(CGFloat)padding {
241 | [self applyPreparedEqualRelationPinConstraintToSuperview:NSLayoutAttributeLeading constant:padding];
242 | }
243 | - (void)applyTrailingPinConstraintToSuperview:(CGFloat)padding {
244 | [self applyPreparedEqualRelationPinConstraintToSuperview:NSLayoutAttributeTrailing constant:-padding];
245 | }
246 | - (void)applyCenterXPinConstraintToSuperview:(CGFloat)padding {
247 | [self applyPreparedEqualRelationPinConstraintToSuperview:NSLayoutAttributeCenterX constant:padding];
248 | }
249 | - (void)applyCenterYPinConstraintToSuperview:(CGFloat)padding {
250 | [self applyPreparedEqualRelationPinConstraintToSuperview:NSLayoutAttributeCenterY constant:padding];
251 | }
252 | - (void)applyLeadingAndTrailingPinConstraintToSuperview:(CGFloat)padding{
253 | [self applyLeadingPinConstraintToSuperview:padding];
254 | [self applyTrailingPinConstraintToSuperview:padding];
255 | }
256 | - (void)applyTopAndBottomPinConstraintToSuperview:(CGFloat)padding{
257 | [self applyTopPinConstraintToSuperview:padding];
258 | [self applyBottomPinConstraintToSuperview:padding];
259 | }
260 | - (void)applyEqualWidthPinConstrainToSuperview {
261 | [self applyPreparedEqualRelationPinConstraintToSuperview:NSLayoutAttributeWidth constant:defaultConstant];
262 | }
263 | - (void)applyEqualHeightPinConstrainToSuperview {
264 | [self applyPreparedEqualRelationPinConstraintToSuperview:NSLayoutAttributeHeight constant:defaultConstant];
265 | }
266 |
267 | - (void)applyEqualHeightRatioPinConstrainToSuperview:(CGFloat)ratio {
268 | [self applyEqualRatioPinConstrainToSuperview:NSLayoutAttributeHeight ratio:ratio padding:defaultConstant];
269 | }
270 |
271 | - (void)applyEqualWidthRatioPinConstrainToSuperview:(CGFloat)ratio {
272 | [self applyEqualRatioPinConstrainToSuperview:NSLayoutAttributeWidth ratio:ratio padding:defaultConstant];
273 | }
274 |
275 | - (void)applyCenterXRatioPinConstrainToSuperview:(CGFloat)ratio padding:(CGFloat)padding {
276 | [self applyEqualRatioPinConstrainToSuperview:NSLayoutAttributeCenterX ratio:ratio padding:padding];
277 | }
278 |
279 | - (void)applyCenterYRatioPinConstrainToSuperview:(CGFloat)ratio padding:(CGFloat)padding {
280 | [self applyEqualRatioPinConstrainToSuperview:NSLayoutAttributeCenterY ratio:ratio padding:padding];
281 | }
282 |
283 | - (void)applyEqualRatioPinConstrainToSuperview:(NSLayoutAttribute)attribute ratio:(CGFloat)ratio padding:(CGFloat)padding{
284 | // first method to get equal Ratio constraint
285 | NSAssert(self.superview, @" Superview of this view must not be nil.\n For View: %@", self);
286 | NSAssert(ratio!=INFINITY, @" Ratio must not be INFINITY.");
287 |
288 | NSLayoutConstraint *relationRatioPinConstraint = [self prepareEqualRelationPinRatioConstraintToSuperview:attribute multiplier:ratio];
289 | if (relationRatioPinConstraint) {
290 | [relationRatioPinConstraint setConstant:padding];
291 | [self.superview applyPreparedConstraintInView:relationRatioPinConstraint];
292 | }
293 | }
294 |
295 | /** Center horizontally and Vertically */
296 | - (void)applyConstraintForCenterInSuperview {
297 | [self applyCenterXPinConstraintToSuperview:defaultConstant];
298 | [self applyCenterYPinConstraintToSuperview:defaultConstant];
299 | }
300 |
301 | - (void)applyConstraintForVerticallyCenterInSuperview {
302 | [self applyCenterYPinConstraintToSuperview:defaultConstant];
303 | }
304 |
305 | - (void)applyConstraintForHorizontallyCenterInSuperview {
306 | [self applyCenterXPinConstraintToSuperview:defaultConstant];
307 | }
308 |
309 | - (void)applyConstraintFitToSuperview {
310 | // First way
311 | [self applyConstraintFitToSuperviewContentInset:UIEdgeInsetsZero];
312 |
313 | // OR Second way to do the same thing
314 | /** [self applyEqualHeightPinConstrainToSuperview];
315 | [self applyEqualWidthPinConstrainToSuperview];
316 | [self applyConstraintForCenterInSuperview];
317 | */
318 | }
319 |
320 | - (void)applyConstraintFitToSuperviewHorizontally{
321 | [self applyTrailingPinConstraintToSuperview:defaultConstant];
322 | [self applyLeadingPinConstraintToSuperview:defaultConstant];
323 | }
324 | - (void)applyConstraintFitToSuperviewVertically{
325 | // INFINITY/HUGE_VALF is used to exclude the constraint from the view
326 | [self applyConstraintFitToSuperviewContentInset:UIEdgeInsetsMake(0, INFINITY, 0, HUGE_VALF)];
327 | }
328 |
329 | - (void)applyConstraintFitToSuperviewContentInset:(UIEdgeInsets)Insets {
330 | if (Insets.top!=INFINITY) {
331 | [self applyTopPinConstraintToSuperview:Insets.top];
332 | }
333 | if (Insets.left!=INFINITY) {
334 | [self applyLeadingPinConstraintToSuperview:Insets.left];
335 | }
336 | if (Insets.bottom!=INFINITY) {
337 | [self applyBottomPinConstraintToSuperview:Insets.bottom];
338 | }
339 | if (Insets.right!=INFINITY) {
340 | [self applyTrailingPinConstraintToSuperview:Insets.right];
341 | }
342 | }
343 |
344 | #pragma mark - Apply self constraints
345 | - (void)applyAspectRatioConstraint {
346 | [self applyPreparedConstraintInView:[self.class prepareConstraintForView:self attribute:NSLayoutAttributeWidth secondView:self attribute:NSLayoutAttributeHeight relation:defaultRelation multiplier:defaultMultiplier]];
347 | }
348 | - (void)applyWidthConstraint:(CGFloat)width {
349 | if (width!=INFINITY) {
350 | [self applyPreparedConstraintInView:[self prepareSelfConstraint:NSLayoutAttributeWidth constant:width]];
351 | }else {
352 | KVLog(@"Width of the view con not be INFINITY");
353 | }
354 | }
355 | - (void)applyHeightConstraint:(CGFloat) height {
356 | if (height!=INFINITY) {
357 | [self applyPreparedConstraintInView:[self prepareSelfConstraint:NSLayoutAttributeHeight constant:height]];
358 | } else {
359 | KVLog(@"Height of the view con not be INFINITY");
360 | }
361 | }
362 |
363 | - (void)applySizeConstraint:(CGSize)size {
364 | [self applyHeightConstraint:size.width];
365 | [self applyHeightConstraint:size.height];
366 | }
367 |
368 | #pragma mark - Apply Constraint between sibling views
369 |
370 | - (void)applyConstraintFromSiblingViewAttribute:(NSLayoutAttribute)attribute toAttribute:(NSLayoutAttribute)toAttribute ofView:(UIView *)otherSiblingView spacing:(CGFloat)spacing {
371 | NSAssert(spacing!=INFINITY, @"spacing between sybings view must not be INFINITY.");
372 |
373 | NSLayoutConstraint *prepareConstraintForSiblingView = [self prepareConstraintFromSiblingViewAttribute:attribute toAttribute:toAttribute ofView:otherSiblingView multiplier:defaultMultiplier];
374 | [prepareConstraintForSiblingView setConstant:spacing];
375 |
376 | if ([NSLayoutConstraint recognizedDirectionByAttribute:attribute toAttribute:toAttribute]) {
377 | [self.superview applyPreparedConstraintInView:[prepareConstraintForSiblingView swapConstraintItems]];
378 | }else {
379 | [self.superview applyPreparedConstraintInView:prepareConstraintForSiblingView];
380 | }
381 | }
382 |
383 | - (void)scaleFontSizeByRatio:(CGFloat)ratio;
384 | {
385 | CGFloat fontSize = 1.0;
386 | UIFont *scaledFont = nil;
387 |
388 | if ([self isKindOfClass:[UILabel class]]) {
389 | UILabel* label = (UILabel*)self;
390 | fontSize = (label.font.pointSize)*ratio;
391 | scaledFont = [UIFont fontWithName:label.font.fontName size:floorf(fontSize)];
392 | [label setFont:scaledFont];
393 | [label setNeedsDisplay];
394 | }
395 | else if ([self isKindOfClass:[UITextField class]])
396 | {
397 | UITextField* textField = (UITextField*)self;
398 | fontSize = (textField.font.pointSize)*ratio;
399 | scaledFont = [UIFont fontWithName:textField.font.fontName size:floorf(fontSize)];
400 | [textField setFont:scaledFont];
401 | [textField setNeedsDisplay];
402 | }
403 | else if ([self isKindOfClass:[UITextView class]])
404 | {
405 | UITextView* textView = (UITextView*)self;
406 | fontSize = (textView.font.pointSize)*ratio;
407 | scaledFont = [UIFont fontWithName:textView.font.fontName size:floorf(fontSize)];
408 | [textView setFont:scaledFont];
409 | [textView setNeedsDisplay];
410 | }
411 | else if ([self isKindOfClass:[UIButton class]])
412 | {
413 | UIButton* button = (UIButton*)self;
414 | fontSize = (button.titleLabel.font.pointSize)*ratio;
415 | scaledFont = [UIFont fontWithName:button.titleLabel.font.fontName size:floorf(fontSize)];
416 | [button.titleLabel setFont:scaledFont];
417 |
418 | // For under line buttons ...
419 | NSAttributedString *attributedString = [button attributedTitleForState:UIControlStateNormal];
420 | if (attributedString.length) {
421 | NSMutableAttributedString * str = [[NSMutableAttributedString alloc] initWithAttributedString:attributedString];
422 | [str addAttribute:NSFontAttributeName value:scaledFont range:NSMakeRange(0,str.length)];
423 | [button setAttributedTitle:str forState:UIControlStateNormal];
424 | }
425 | [button setNeedsDisplay];
426 | }
427 | else{
428 |
429 | }
430 | }
431 |
432 |
433 | @end
434 |
--------------------------------------------------------------------------------
/KVConstraintExtensionsExample/KVConstraintExtensionsExample.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 049B24741B8A5B78009ED565 /* KV_ApplySimpleConstraintVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 049B24731B8A5B78009ED565 /* KV_ApplySimpleConstraintVC.m */; };
11 | 049B24781B8A5C77009ED565 /* KV_MultipleConstraintsVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 049B24771B8A5C77009ED565 /* KV_MultipleConstraintsVC.m */; };
12 | 049B247B1B8A5C87009ED565 /* KV_ApplyRatioConstraintVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 049B247A1B8A5C87009ED565 /* KV_ApplyRatioConstraintVC.m */; };
13 | 049B247E1B8A5C95009ED565 /* KV_ModifyConstraintVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 049B247D1B8A5C95009ED565 /* KV_ModifyConstraintVC.m */; };
14 | 049B24811B8A5CA4009ED565 /* KV_ChangeStoryboardConstraintVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 049B24801B8A5CA4009ED565 /* KV_ChangeStoryboardConstraintVC.m */; };
15 | 049B24841B8A5CB7009ED565 /* KV_ApplyLayoutGuideConstraintVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 049B24831B8A5CB7009ED565 /* KV_ApplyLayoutGuideConstraintVC.m */; };
16 | 049B24881B8A6291009ED565 /* UIColor+KVExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 049B24871B8A6291009ED565 /* UIColor+KVExtensions.m */; };
17 | 049B248B1B8A6901009ED565 /* KV_BaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 049B248A1B8A6901009ED565 /* KV_BaseViewController.m */; };
18 | 049D9EA51B7BC414007FFBB3 /* NSLayoutConstraint+KVConstraintExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 049D9EA21B7BC414007FFBB3 /* NSLayoutConstraint+KVConstraintExtensions.m */; };
19 | 049D9EA61B7BC414007FFBB3 /* UIView+KVConstraintExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 049D9EA41B7BC414007FFBB3 /* UIView+KVConstraintExtensions.m */; };
20 | 04A0682C1B8CFDC900984C9C /* KV_SiblingConstraintVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A0682B1B8CFDC900984C9C /* KV_SiblingConstraintVC.m */; };
21 | 04A1535B1B6FFBDC0004D1A9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04A1535A1B6FFBDC0004D1A9 /* Foundation.framework */; };
22 | 04A1535D1B6FFBDC0004D1A9 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04A1535C1B6FFBDC0004D1A9 /* CoreGraphics.framework */; };
23 | 04A1535F1B6FFBDC0004D1A9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04A1535E1B6FFBDC0004D1A9 /* UIKit.framework */; };
24 | 04A153651B6FFBDC0004D1A9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 04A153631B6FFBDC0004D1A9 /* InfoPlist.strings */; };
25 | 04A153671B6FFBDC0004D1A9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A153661B6FFBDC0004D1A9 /* main.m */; };
26 | 04A1536B1B6FFBDC0004D1A9 /* KV_AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A1536A1B6FFBDC0004D1A9 /* KV_AppDelegate.m */; };
27 | 04A1536E1B6FFBDC0004D1A9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 04A1536C1B6FFBDC0004D1A9 /* Main.storyboard */; };
28 | 04A153711B6FFBDC0004D1A9 /* KV_ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A153701B6FFBDC0004D1A9 /* KV_ViewController.m */; };
29 | 04A153731B6FFBDC0004D1A9 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 04A153721B6FFBDC0004D1A9 /* Images.xcassets */; };
30 | 04A1537A1B6FFBDC0004D1A9 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04A153791B6FFBDC0004D1A9 /* XCTest.framework */; };
31 | 04A1537B1B6FFBDC0004D1A9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04A1535A1B6FFBDC0004D1A9 /* Foundation.framework */; };
32 | 04A1537C1B6FFBDC0004D1A9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04A1535E1B6FFBDC0004D1A9 /* UIKit.framework */; };
33 | 04A153841B6FFBDD0004D1A9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 04A153821B6FFBDD0004D1A9 /* InfoPlist.strings */; };
34 | 04A153861B6FFBDD0004D1A9 /* KVConstraintExtensionsExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A153851B6FFBDD0004D1A9 /* KVConstraintExtensionsExampleTests.m */; };
35 | 04A16C5D1B83B8320000A854 /* UIViewController+KVConstraintExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A16C5C1B83B8320000A854 /* UIViewController+KVConstraintExtensions.m */; };
36 | 04A904391BB082D500E12A72 /* KV_ConstraintWithAnimationVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A904381BB082D500E12A72 /* KV_ConstraintWithAnimationVC.m */; };
37 | 6B1533FD1D57F3C600262018 /* KV_ApplySimpleRatioConstraintVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B1533FC1D57F3C600262018 /* KV_ApplySimpleRatioConstraintVC.m */; };
38 | /* End PBXBuildFile section */
39 |
40 | /* Begin PBXContainerItemProxy section */
41 | 04A1537D1B6FFBDD0004D1A9 /* PBXContainerItemProxy */ = {
42 | isa = PBXContainerItemProxy;
43 | containerPortal = 04A1534F1B6FFBDC0004D1A9 /* Project object */;
44 | proxyType = 1;
45 | remoteGlobalIDString = 04A153561B6FFBDC0004D1A9;
46 | remoteInfo = KVConstraintExtensionsExample;
47 | };
48 | /* End PBXContainerItemProxy section */
49 |
50 | /* Begin PBXFileReference section */
51 | 049B24721B8A5B78009ED565 /* KV_ApplySimpleConstraintVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KV_ApplySimpleConstraintVC.h; sourceTree = ""; };
52 | 049B24731B8A5B78009ED565 /* KV_ApplySimpleConstraintVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KV_ApplySimpleConstraintVC.m; sourceTree = ""; };
53 | 049B24761B8A5C77009ED565 /* KV_MultipleConstraintsVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KV_MultipleConstraintsVC.h; sourceTree = ""; };
54 | 049B24771B8A5C77009ED565 /* KV_MultipleConstraintsVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KV_MultipleConstraintsVC.m; sourceTree = ""; };
55 | 049B24791B8A5C87009ED565 /* KV_ApplyRatioConstraintVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KV_ApplyRatioConstraintVC.h; sourceTree = ""; };
56 | 049B247A1B8A5C87009ED565 /* KV_ApplyRatioConstraintVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KV_ApplyRatioConstraintVC.m; sourceTree = ""; };
57 | 049B247C1B8A5C95009ED565 /* KV_ModifyConstraintVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KV_ModifyConstraintVC.h; sourceTree = ""; };
58 | 049B247D1B8A5C95009ED565 /* KV_ModifyConstraintVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KV_ModifyConstraintVC.m; sourceTree = ""; };
59 | 049B247F1B8A5CA4009ED565 /* KV_ChangeStoryboardConstraintVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KV_ChangeStoryboardConstraintVC.h; sourceTree = ""; };
60 | 049B24801B8A5CA4009ED565 /* KV_ChangeStoryboardConstraintVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KV_ChangeStoryboardConstraintVC.m; sourceTree = ""; };
61 | 049B24821B8A5CB7009ED565 /* KV_ApplyLayoutGuideConstraintVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KV_ApplyLayoutGuideConstraintVC.h; sourceTree = ""; };
62 | 049B24831B8A5CB7009ED565 /* KV_ApplyLayoutGuideConstraintVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KV_ApplyLayoutGuideConstraintVC.m; sourceTree = ""; };
63 | 049B24861B8A6291009ED565 /* UIColor+KVExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+KVExtensions.h"; sourceTree = ""; };
64 | 049B24871B8A6291009ED565 /* UIColor+KVExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+KVExtensions.m"; sourceTree = ""; };
65 | 049B24891B8A6901009ED565 /* KV_BaseViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KV_BaseViewController.h; sourceTree = ""; };
66 | 049B248A1B8A6901009ED565 /* KV_BaseViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KV_BaseViewController.m; sourceTree = ""; };
67 | 049D9EA11B7BC414007FFBB3 /* NSLayoutConstraint+KVConstraintExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSLayoutConstraint+KVConstraintExtensions.h"; sourceTree = ""; };
68 | 049D9EA21B7BC414007FFBB3 /* NSLayoutConstraint+KVConstraintExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSLayoutConstraint+KVConstraintExtensions.m"; sourceTree = ""; };
69 | 049D9EA31B7BC414007FFBB3 /* UIView+KVConstraintExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+KVConstraintExtensions.h"; sourceTree = ""; };
70 | 049D9EA41B7BC414007FFBB3 /* UIView+KVConstraintExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+KVConstraintExtensions.m"; sourceTree = ""; };
71 | 04A0682A1B8CFDC900984C9C /* KV_SiblingConstraintVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KV_SiblingConstraintVC.h; sourceTree = ""; };
72 | 04A0682B1B8CFDC900984C9C /* KV_SiblingConstraintVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KV_SiblingConstraintVC.m; sourceTree = ""; };
73 | 04A153571B6FFBDC0004D1A9 /* KVConstraintExtensionsExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KVConstraintExtensionsExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
74 | 04A1535A1B6FFBDC0004D1A9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
75 | 04A1535C1B6FFBDC0004D1A9 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
76 | 04A1535E1B6FFBDC0004D1A9 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
77 | 04A153621B6FFBDC0004D1A9 /* KVConstraintExtensionsExample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "KVConstraintExtensionsExample-Info.plist"; sourceTree = ""; };
78 | 04A153641B6FFBDC0004D1A9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
79 | 04A153661B6FFBDC0004D1A9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
80 | 04A153681B6FFBDC0004D1A9 /* KVConstraintExtensionsExample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "KVConstraintExtensionsExample-Prefix.pch"; sourceTree = ""; };
81 | 04A153691B6FFBDC0004D1A9 /* KV_AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KV_AppDelegate.h; sourceTree = ""; };
82 | 04A1536A1B6FFBDC0004D1A9 /* KV_AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KV_AppDelegate.m; sourceTree = ""; };
83 | 04A1536D1B6FFBDC0004D1A9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
84 | 04A1536F1B6FFBDC0004D1A9 /* KV_ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KV_ViewController.h; sourceTree = ""; };
85 | 04A153701B6FFBDC0004D1A9 /* KV_ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KV_ViewController.m; sourceTree = ""; };
86 | 04A153721B6FFBDC0004D1A9 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
87 | 04A153781B6FFBDC0004D1A9 /* KVConstraintExtensionsExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = KVConstraintExtensionsExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
88 | 04A153791B6FFBDC0004D1A9 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
89 | 04A153811B6FFBDD0004D1A9 /* KVConstraintExtensionsExampleTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "KVConstraintExtensionsExampleTests-Info.plist"; sourceTree = ""; };
90 | 04A153831B6FFBDD0004D1A9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
91 | 04A153851B6FFBDD0004D1A9 /* KVConstraintExtensionsExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KVConstraintExtensionsExampleTests.m; sourceTree = ""; };
92 | 04A16C5B1B83B8320000A854 /* UIViewController+KVConstraintExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+KVConstraintExtensions.h"; sourceTree = ""; };
93 | 04A16C5C1B83B8320000A854 /* UIViewController+KVConstraintExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+KVConstraintExtensions.m"; sourceTree = ""; };
94 | 04A2601E1BA4186E00AD55F8 /* KVConstraintExtensionsMaster.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KVConstraintExtensionsMaster.h; sourceTree = ""; };
95 | 04A904371BB082D500E12A72 /* KV_ConstraintWithAnimationVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KV_ConstraintWithAnimationVC.h; sourceTree = ""; };
96 | 04A904381BB082D500E12A72 /* KV_ConstraintWithAnimationVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KV_ConstraintWithAnimationVC.m; sourceTree = ""; };
97 | 6B1533FB1D57F3C600262018 /* KV_ApplySimpleRatioConstraintVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KV_ApplySimpleRatioConstraintVC.h; sourceTree = ""; };
98 | 6B1533FC1D57F3C600262018 /* KV_ApplySimpleRatioConstraintVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KV_ApplySimpleRatioConstraintVC.m; sourceTree = ""; };
99 | /* End PBXFileReference section */
100 |
101 | /* Begin PBXFrameworksBuildPhase section */
102 | 04A153541B6FFBDC0004D1A9 /* Frameworks */ = {
103 | isa = PBXFrameworksBuildPhase;
104 | buildActionMask = 2147483647;
105 | files = (
106 | 04A1535D1B6FFBDC0004D1A9 /* CoreGraphics.framework in Frameworks */,
107 | 04A1535F1B6FFBDC0004D1A9 /* UIKit.framework in Frameworks */,
108 | 04A1535B1B6FFBDC0004D1A9 /* Foundation.framework in Frameworks */,
109 | );
110 | runOnlyForDeploymentPostprocessing = 0;
111 | };
112 | 04A153751B6FFBDC0004D1A9 /* Frameworks */ = {
113 | isa = PBXFrameworksBuildPhase;
114 | buildActionMask = 2147483647;
115 | files = (
116 | 04A1537A1B6FFBDC0004D1A9 /* XCTest.framework in Frameworks */,
117 | 04A1537C1B6FFBDC0004D1A9 /* UIKit.framework in Frameworks */,
118 | 04A1537B1B6FFBDC0004D1A9 /* Foundation.framework in Frameworks */,
119 | );
120 | runOnlyForDeploymentPostprocessing = 0;
121 | };
122 | /* End PBXFrameworksBuildPhase section */
123 |
124 | /* Begin PBXGroup section */
125 | 049B24751B8A5C32009ED565 /* KV_ViewControllers */ = {
126 | isa = PBXGroup;
127 | children = (
128 | 049B24891B8A6901009ED565 /* KV_BaseViewController.h */,
129 | 049B248A1B8A6901009ED565 /* KV_BaseViewController.m */,
130 | 04A1536F1B6FFBDC0004D1A9 /* KV_ViewController.h */,
131 | 04A153701B6FFBDC0004D1A9 /* KV_ViewController.m */,
132 | 049B24721B8A5B78009ED565 /* KV_ApplySimpleConstraintVC.h */,
133 | 049B24731B8A5B78009ED565 /* KV_ApplySimpleConstraintVC.m */,
134 | 049B24761B8A5C77009ED565 /* KV_MultipleConstraintsVC.h */,
135 | 049B24771B8A5C77009ED565 /* KV_MultipleConstraintsVC.m */,
136 | 6B1533FB1D57F3C600262018 /* KV_ApplySimpleRatioConstraintVC.h */,
137 | 6B1533FC1D57F3C600262018 /* KV_ApplySimpleRatioConstraintVC.m */,
138 | 049B24791B8A5C87009ED565 /* KV_ApplyRatioConstraintVC.h */,
139 | 049B247A1B8A5C87009ED565 /* KV_ApplyRatioConstraintVC.m */,
140 | 049B24821B8A5CB7009ED565 /* KV_ApplyLayoutGuideConstraintVC.h */,
141 | 049B24831B8A5CB7009ED565 /* KV_ApplyLayoutGuideConstraintVC.m */,
142 | 049B247C1B8A5C95009ED565 /* KV_ModifyConstraintVC.h */,
143 | 049B247D1B8A5C95009ED565 /* KV_ModifyConstraintVC.m */,
144 | 04A904371BB082D500E12A72 /* KV_ConstraintWithAnimationVC.h */,
145 | 04A904381BB082D500E12A72 /* KV_ConstraintWithAnimationVC.m */,
146 | 049B247F1B8A5CA4009ED565 /* KV_ChangeStoryboardConstraintVC.h */,
147 | 049B24801B8A5CA4009ED565 /* KV_ChangeStoryboardConstraintVC.m */,
148 | 04A0682A1B8CFDC900984C9C /* KV_SiblingConstraintVC.h */,
149 | 04A0682B1B8CFDC900984C9C /* KV_SiblingConstraintVC.m */,
150 | );
151 | name = KV_ViewControllers;
152 | sourceTree = "";
153 | };
154 | 049B24851B8A6282009ED565 /* UIColor+KVExtensions */ = {
155 | isa = PBXGroup;
156 | children = (
157 | 049B24861B8A6291009ED565 /* UIColor+KVExtensions.h */,
158 | 049B24871B8A6291009ED565 /* UIColor+KVExtensions.m */,
159 | );
160 | name = "UIColor+KVExtensions";
161 | sourceTree = "";
162 | };
163 | 049D9E9F1B7BC414007FFBB3 /* KVConstraintExtensionsMaster */ = {
164 | isa = PBXGroup;
165 | children = (
166 | 04A2601E1BA4186E00AD55F8 /* KVConstraintExtensionsMaster.h */,
167 | 049D9EA31B7BC414007FFBB3 /* UIView+KVConstraintExtensions.h */,
168 | 049D9EA41B7BC414007FFBB3 /* UIView+KVConstraintExtensions.m */,
169 | 04A16C5B1B83B8320000A854 /* UIViewController+KVConstraintExtensions.h */,
170 | 04A16C5C1B83B8320000A854 /* UIViewController+KVConstraintExtensions.m */,
171 | 049D9EA11B7BC414007FFBB3 /* NSLayoutConstraint+KVConstraintExtensions.h */,
172 | 049D9EA21B7BC414007FFBB3 /* NSLayoutConstraint+KVConstraintExtensions.m */,
173 | );
174 | name = KVConstraintExtensionsMaster;
175 | path = ../KVConstraintExtensionsMaster;
176 | sourceTree = SOURCE_ROOT;
177 | };
178 | 04A1534E1B6FFBDC0004D1A9 = {
179 | isa = PBXGroup;
180 | children = (
181 | 04A153601B6FFBDC0004D1A9 /* KVConstraintExtensionsExample */,
182 | 04A153591B6FFBDC0004D1A9 /* Frameworks */,
183 | 04A153581B6FFBDC0004D1A9 /* Products */,
184 | );
185 | sourceTree = "";
186 | };
187 | 04A153581B6FFBDC0004D1A9 /* Products */ = {
188 | isa = PBXGroup;
189 | children = (
190 | 04A153571B6FFBDC0004D1A9 /* KVConstraintExtensionsExample.app */,
191 | 04A153781B6FFBDC0004D1A9 /* KVConstraintExtensionsExampleTests.xctest */,
192 | );
193 | name = Products;
194 | sourceTree = "";
195 | };
196 | 04A153591B6FFBDC0004D1A9 /* Frameworks */ = {
197 | isa = PBXGroup;
198 | children = (
199 | 04A1535A1B6FFBDC0004D1A9 /* Foundation.framework */,
200 | 04A1535C1B6FFBDC0004D1A9 /* CoreGraphics.framework */,
201 | 04A1535E1B6FFBDC0004D1A9 /* UIKit.framework */,
202 | 04A153791B6FFBDC0004D1A9 /* XCTest.framework */,
203 | );
204 | name = Frameworks;
205 | sourceTree = "";
206 | };
207 | 04A153601B6FFBDC0004D1A9 /* KVConstraintExtensionsExample */ = {
208 | isa = PBXGroup;
209 | children = (
210 | 049D9E9F1B7BC414007FFBB3 /* KVConstraintExtensionsMaster */,
211 | 04A153691B6FFBDC0004D1A9 /* KV_AppDelegate.h */,
212 | 04A1536A1B6FFBDC0004D1A9 /* KV_AppDelegate.m */,
213 | 04A1536C1B6FFBDC0004D1A9 /* Main.storyboard */,
214 | 049B24751B8A5C32009ED565 /* KV_ViewControllers */,
215 | 04A153721B6FFBDC0004D1A9 /* Images.xcassets */,
216 | 04A153611B6FFBDC0004D1A9 /* Supporting Files */,
217 | 04A1537F1B6FFBDD0004D1A9 /* KVConstraintExtensionsExampleTests */,
218 | );
219 | path = KVConstraintExtensionsExample;
220 | sourceTree = "";
221 | };
222 | 04A153611B6FFBDC0004D1A9 /* Supporting Files */ = {
223 | isa = PBXGroup;
224 | children = (
225 | 049B24851B8A6282009ED565 /* UIColor+KVExtensions */,
226 | 04A153621B6FFBDC0004D1A9 /* KVConstraintExtensionsExample-Info.plist */,
227 | 04A153631B6FFBDC0004D1A9 /* InfoPlist.strings */,
228 | 04A153661B6FFBDC0004D1A9 /* main.m */,
229 | 04A153681B6FFBDC0004D1A9 /* KVConstraintExtensionsExample-Prefix.pch */,
230 | );
231 | name = "Supporting Files";
232 | sourceTree = "";
233 | };
234 | 04A1537F1B6FFBDD0004D1A9 /* KVConstraintExtensionsExampleTests */ = {
235 | isa = PBXGroup;
236 | children = (
237 | 04A153851B6FFBDD0004D1A9 /* KVConstraintExtensionsExampleTests.m */,
238 | 04A153801B6FFBDD0004D1A9 /* Supporting Files */,
239 | );
240 | path = KVConstraintExtensionsExampleTests;
241 | sourceTree = SOURCE_ROOT;
242 | };
243 | 04A153801B6FFBDD0004D1A9 /* Supporting Files */ = {
244 | isa = PBXGroup;
245 | children = (
246 | 04A153811B6FFBDD0004D1A9 /* KVConstraintExtensionsExampleTests-Info.plist */,
247 | 04A153821B6FFBDD0004D1A9 /* InfoPlist.strings */,
248 | );
249 | name = "Supporting Files";
250 | sourceTree = "";
251 | };
252 | /* End PBXGroup section */
253 |
254 | /* Begin PBXNativeTarget section */
255 | 04A153561B6FFBDC0004D1A9 /* KVConstraintExtensionsExample */ = {
256 | isa = PBXNativeTarget;
257 | buildConfigurationList = 04A153891B6FFBDD0004D1A9 /* Build configuration list for PBXNativeTarget "KVConstraintExtensionsExample" */;
258 | buildPhases = (
259 | 04A153531B6FFBDC0004D1A9 /* Sources */,
260 | 04A153541B6FFBDC0004D1A9 /* Frameworks */,
261 | 04A153551B6FFBDC0004D1A9 /* Resources */,
262 | );
263 | buildRules = (
264 | );
265 | dependencies = (
266 | );
267 | name = KVConstraintExtensionsExample;
268 | productName = KVConstraintExtensionsExample;
269 | productReference = 04A153571B6FFBDC0004D1A9 /* KVConstraintExtensionsExample.app */;
270 | productType = "com.apple.product-type.application";
271 | };
272 | 04A153771B6FFBDC0004D1A9 /* KVConstraintExtensionsExampleTests */ = {
273 | isa = PBXNativeTarget;
274 | buildConfigurationList = 04A1538C1B6FFBDD0004D1A9 /* Build configuration list for PBXNativeTarget "KVConstraintExtensionsExampleTests" */;
275 | buildPhases = (
276 | 04A153741B6FFBDC0004D1A9 /* Sources */,
277 | 04A153751B6FFBDC0004D1A9 /* Frameworks */,
278 | 04A153761B6FFBDC0004D1A9 /* Resources */,
279 | );
280 | buildRules = (
281 | );
282 | dependencies = (
283 | 04A1537E1B6FFBDD0004D1A9 /* PBXTargetDependency */,
284 | );
285 | name = KVConstraintExtensionsExampleTests;
286 | productName = KVConstraintExtensionsExampleTests;
287 | productReference = 04A153781B6FFBDC0004D1A9 /* KVConstraintExtensionsExampleTests.xctest */;
288 | productType = "com.apple.product-type.bundle.unit-test";
289 | };
290 | /* End PBXNativeTarget section */
291 |
292 | /* Begin PBXProject section */
293 | 04A1534F1B6FFBDC0004D1A9 /* Project object */ = {
294 | isa = PBXProject;
295 | attributes = {
296 | CLASSPREFIX = KV_;
297 | LastUpgradeCheck = 0720;
298 | ORGANIZATIONNAME = Keshav;
299 | TargetAttributes = {
300 | 04A153771B6FFBDC0004D1A9 = {
301 | TestTargetID = 04A153561B6FFBDC0004D1A9;
302 | };
303 | };
304 | };
305 | buildConfigurationList = 04A153521B6FFBDC0004D1A9 /* Build configuration list for PBXProject "KVConstraintExtensionsExample" */;
306 | compatibilityVersion = "Xcode 3.2";
307 | developmentRegion = English;
308 | hasScannedForEncodings = 0;
309 | knownRegions = (
310 | en,
311 | Base,
312 | );
313 | mainGroup = 04A1534E1B6FFBDC0004D1A9;
314 | productRefGroup = 04A153581B6FFBDC0004D1A9 /* Products */;
315 | projectDirPath = "";
316 | projectRoot = "";
317 | targets = (
318 | 04A153561B6FFBDC0004D1A9 /* KVConstraintExtensionsExample */,
319 | 04A153771B6FFBDC0004D1A9 /* KVConstraintExtensionsExampleTests */,
320 | );
321 | };
322 | /* End PBXProject section */
323 |
324 | /* Begin PBXResourcesBuildPhase section */
325 | 04A153551B6FFBDC0004D1A9 /* Resources */ = {
326 | isa = PBXResourcesBuildPhase;
327 | buildActionMask = 2147483647;
328 | files = (
329 | 04A153731B6FFBDC0004D1A9 /* Images.xcassets in Resources */,
330 | 04A153651B6FFBDC0004D1A9 /* InfoPlist.strings in Resources */,
331 | 04A1536E1B6FFBDC0004D1A9 /* Main.storyboard in Resources */,
332 | );
333 | runOnlyForDeploymentPostprocessing = 0;
334 | };
335 | 04A153761B6FFBDC0004D1A9 /* Resources */ = {
336 | isa = PBXResourcesBuildPhase;
337 | buildActionMask = 2147483647;
338 | files = (
339 | 04A153841B6FFBDD0004D1A9 /* InfoPlist.strings in Resources */,
340 | );
341 | runOnlyForDeploymentPostprocessing = 0;
342 | };
343 | /* End PBXResourcesBuildPhase section */
344 |
345 | /* Begin PBXSourcesBuildPhase section */
346 | 04A153531B6FFBDC0004D1A9 /* Sources */ = {
347 | isa = PBXSourcesBuildPhase;
348 | buildActionMask = 2147483647;
349 | files = (
350 | 04A0682C1B8CFDC900984C9C /* KV_SiblingConstraintVC.m in Sources */,
351 | 04A16C5D1B83B8320000A854 /* UIViewController+KVConstraintExtensions.m in Sources */,
352 | 04A153711B6FFBDC0004D1A9 /* KV_ViewController.m in Sources */,
353 | 04A904391BB082D500E12A72 /* KV_ConstraintWithAnimationVC.m in Sources */,
354 | 049B24781B8A5C77009ED565 /* KV_MultipleConstraintsVC.m in Sources */,
355 | 049D9EA61B7BC414007FFBB3 /* UIView+KVConstraintExtensions.m in Sources */,
356 | 049B247E1B8A5C95009ED565 /* KV_ModifyConstraintVC.m in Sources */,
357 | 049B24811B8A5CA4009ED565 /* KV_ChangeStoryboardConstraintVC.m in Sources */,
358 | 04A153671B6FFBDC0004D1A9 /* main.m in Sources */,
359 | 049B247B1B8A5C87009ED565 /* KV_ApplyRatioConstraintVC.m in Sources */,
360 | 6B1533FD1D57F3C600262018 /* KV_ApplySimpleRatioConstraintVC.m in Sources */,
361 | 049B24841B8A5CB7009ED565 /* KV_ApplyLayoutGuideConstraintVC.m in Sources */,
362 | 049B24741B8A5B78009ED565 /* KV_ApplySimpleConstraintVC.m in Sources */,
363 | 04A1536B1B6FFBDC0004D1A9 /* KV_AppDelegate.m in Sources */,
364 | 049B24881B8A6291009ED565 /* UIColor+KVExtensions.m in Sources */,
365 | 049B248B1B8A6901009ED565 /* KV_BaseViewController.m in Sources */,
366 | 049D9EA51B7BC414007FFBB3 /* NSLayoutConstraint+KVConstraintExtensions.m in Sources */,
367 | );
368 | runOnlyForDeploymentPostprocessing = 0;
369 | };
370 | 04A153741B6FFBDC0004D1A9 /* Sources */ = {
371 | isa = PBXSourcesBuildPhase;
372 | buildActionMask = 2147483647;
373 | files = (
374 | 04A153861B6FFBDD0004D1A9 /* KVConstraintExtensionsExampleTests.m in Sources */,
375 | );
376 | runOnlyForDeploymentPostprocessing = 0;
377 | };
378 | /* End PBXSourcesBuildPhase section */
379 |
380 | /* Begin PBXTargetDependency section */
381 | 04A1537E1B6FFBDD0004D1A9 /* PBXTargetDependency */ = {
382 | isa = PBXTargetDependency;
383 | target = 04A153561B6FFBDC0004D1A9 /* KVConstraintExtensionsExample */;
384 | targetProxy = 04A1537D1B6FFBDD0004D1A9 /* PBXContainerItemProxy */;
385 | };
386 | /* End PBXTargetDependency section */
387 |
388 | /* Begin PBXVariantGroup section */
389 | 04A153631B6FFBDC0004D1A9 /* InfoPlist.strings */ = {
390 | isa = PBXVariantGroup;
391 | children = (
392 | 04A153641B6FFBDC0004D1A9 /* en */,
393 | );
394 | name = InfoPlist.strings;
395 | sourceTree = "";
396 | };
397 | 04A1536C1B6FFBDC0004D1A9 /* Main.storyboard */ = {
398 | isa = PBXVariantGroup;
399 | children = (
400 | 04A1536D1B6FFBDC0004D1A9 /* Base */,
401 | );
402 | name = Main.storyboard;
403 | sourceTree = "";
404 | };
405 | 04A153821B6FFBDD0004D1A9 /* InfoPlist.strings */ = {
406 | isa = PBXVariantGroup;
407 | children = (
408 | 04A153831B6FFBDD0004D1A9 /* en */,
409 | );
410 | name = InfoPlist.strings;
411 | sourceTree = "";
412 | };
413 | /* End PBXVariantGroup section */
414 |
415 | /* Begin XCBuildConfiguration section */
416 | 04A153871B6FFBDD0004D1A9 /* Debug */ = {
417 | isa = XCBuildConfiguration;
418 | buildSettings = {
419 | ALWAYS_SEARCH_USER_PATHS = NO;
420 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
421 | CLANG_CXX_LIBRARY = "libc++";
422 | CLANG_ENABLE_MODULES = YES;
423 | CLANG_ENABLE_OBJC_ARC = YES;
424 | CLANG_WARN_BOOL_CONVERSION = YES;
425 | CLANG_WARN_CONSTANT_CONVERSION = YES;
426 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
427 | CLANG_WARN_EMPTY_BODY = YES;
428 | CLANG_WARN_ENUM_CONVERSION = YES;
429 | CLANG_WARN_INT_CONVERSION = YES;
430 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
431 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
432 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
433 | COPY_PHASE_STRIP = NO;
434 | ENABLE_TESTABILITY = YES;
435 | GCC_C_LANGUAGE_STANDARD = gnu99;
436 | GCC_DYNAMIC_NO_PIC = NO;
437 | GCC_OPTIMIZATION_LEVEL = 0;
438 | GCC_PREPROCESSOR_DEFINITIONS = (
439 | "DEBUG=1",
440 | "$(inherited)",
441 | );
442 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
443 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
444 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
445 | GCC_WARN_UNDECLARED_SELECTOR = YES;
446 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
447 | GCC_WARN_UNUSED_FUNCTION = YES;
448 | GCC_WARN_UNUSED_VARIABLE = YES;
449 | IPHONEOS_DEPLOYMENT_TARGET = 8.4;
450 | ONLY_ACTIVE_ARCH = YES;
451 | SDKROOT = iphoneos;
452 | };
453 | name = Debug;
454 | };
455 | 04A153881B6FFBDD0004D1A9 /* Release */ = {
456 | isa = XCBuildConfiguration;
457 | buildSettings = {
458 | ALWAYS_SEARCH_USER_PATHS = NO;
459 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
460 | CLANG_CXX_LIBRARY = "libc++";
461 | CLANG_ENABLE_MODULES = YES;
462 | CLANG_ENABLE_OBJC_ARC = YES;
463 | CLANG_WARN_BOOL_CONVERSION = YES;
464 | CLANG_WARN_CONSTANT_CONVERSION = YES;
465 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
466 | CLANG_WARN_EMPTY_BODY = YES;
467 | CLANG_WARN_ENUM_CONVERSION = YES;
468 | CLANG_WARN_INT_CONVERSION = YES;
469 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
470 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
471 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
472 | COPY_PHASE_STRIP = YES;
473 | ENABLE_NS_ASSERTIONS = NO;
474 | GCC_C_LANGUAGE_STANDARD = gnu99;
475 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
476 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
477 | GCC_WARN_UNDECLARED_SELECTOR = YES;
478 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
479 | GCC_WARN_UNUSED_FUNCTION = YES;
480 | GCC_WARN_UNUSED_VARIABLE = YES;
481 | IPHONEOS_DEPLOYMENT_TARGET = 8.4;
482 | SDKROOT = iphoneos;
483 | VALIDATE_PRODUCT = YES;
484 | };
485 | name = Release;
486 | };
487 | 04A1538A1B6FFBDD0004D1A9 /* Debug */ = {
488 | isa = XCBuildConfiguration;
489 | buildSettings = {
490 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
491 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
492 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
493 | GCC_PREFIX_HEADER = "KVConstraintExtensionsExample/KVConstraintExtensionsExample-Prefix.pch";
494 | INFOPLIST_FILE = "KVConstraintExtensionsExample/KVConstraintExtensionsExample-Info.plist";
495 | IPHONEOS_DEPLOYMENT_TARGET = 7.0;
496 | PRODUCT_BUNDLE_IDENTIFIER = "Keshav.${PRODUCT_NAME:rfc1034identifier}";
497 | PRODUCT_NAME = "$(TARGET_NAME)";
498 | TARGETED_DEVICE_FAMILY = "1,2";
499 | WRAPPER_EXTENSION = app;
500 | };
501 | name = Debug;
502 | };
503 | 04A1538B1B6FFBDD0004D1A9 /* Release */ = {
504 | isa = XCBuildConfiguration;
505 | buildSettings = {
506 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
507 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
508 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
509 | GCC_PREFIX_HEADER = "KVConstraintExtensionsExample/KVConstraintExtensionsExample-Prefix.pch";
510 | INFOPLIST_FILE = "KVConstraintExtensionsExample/KVConstraintExtensionsExample-Info.plist";
511 | IPHONEOS_DEPLOYMENT_TARGET = 7.0;
512 | PRODUCT_BUNDLE_IDENTIFIER = "Keshav.${PRODUCT_NAME:rfc1034identifier}";
513 | PRODUCT_NAME = "$(TARGET_NAME)";
514 | TARGETED_DEVICE_FAMILY = "1,2";
515 | WRAPPER_EXTENSION = app;
516 | };
517 | name = Release;
518 | };
519 | 04A1538D1B6FFBDD0004D1A9 /* Debug */ = {
520 | isa = XCBuildConfiguration;
521 | buildSettings = {
522 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/KVConstraintExtensionsExample.app/KVConstraintExtensionsExample";
523 | FRAMEWORK_SEARCH_PATHS = (
524 | "$(SDKROOT)/Developer/Library/Frameworks",
525 | "$(inherited)",
526 | "$(DEVELOPER_FRAMEWORKS_DIR)",
527 | );
528 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
529 | GCC_PREFIX_HEADER = "KVConstraintExtensionsExample/KVConstraintExtensionsExample-Prefix.pch";
530 | GCC_PREPROCESSOR_DEFINITIONS = (
531 | "DEBUG=1",
532 | "$(inherited)",
533 | );
534 | INFOPLIST_FILE = "KVConstraintExtensionsExampleTests/KVConstraintExtensionsExampleTests-Info.plist";
535 | PRODUCT_BUNDLE_IDENTIFIER = "Keshav.${PRODUCT_NAME:rfc1034identifier}";
536 | PRODUCT_NAME = "$(TARGET_NAME)";
537 | TEST_HOST = "$(BUNDLE_LOADER)";
538 | WRAPPER_EXTENSION = xctest;
539 | };
540 | name = Debug;
541 | };
542 | 04A1538E1B6FFBDD0004D1A9 /* Release */ = {
543 | isa = XCBuildConfiguration;
544 | buildSettings = {
545 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/KVConstraintExtensionsExample.app/KVConstraintExtensionsExample";
546 | FRAMEWORK_SEARCH_PATHS = (
547 | "$(SDKROOT)/Developer/Library/Frameworks",
548 | "$(inherited)",
549 | "$(DEVELOPER_FRAMEWORKS_DIR)",
550 | );
551 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
552 | GCC_PREFIX_HEADER = "KVConstraintExtensionsExample/KVConstraintExtensionsExample-Prefix.pch";
553 | INFOPLIST_FILE = "KVConstraintExtensionsExampleTests/KVConstraintExtensionsExampleTests-Info.plist";
554 | PRODUCT_BUNDLE_IDENTIFIER = "Keshav.${PRODUCT_NAME:rfc1034identifier}";
555 | PRODUCT_NAME = "$(TARGET_NAME)";
556 | TEST_HOST = "$(BUNDLE_LOADER)";
557 | WRAPPER_EXTENSION = xctest;
558 | };
559 | name = Release;
560 | };
561 | /* End XCBuildConfiguration section */
562 |
563 | /* Begin XCConfigurationList section */
564 | 04A153521B6FFBDC0004D1A9 /* Build configuration list for PBXProject "KVConstraintExtensionsExample" */ = {
565 | isa = XCConfigurationList;
566 | buildConfigurations = (
567 | 04A153871B6FFBDD0004D1A9 /* Debug */,
568 | 04A153881B6FFBDD0004D1A9 /* Release */,
569 | );
570 | defaultConfigurationIsVisible = 0;
571 | defaultConfigurationName = Release;
572 | };
573 | 04A153891B6FFBDD0004D1A9 /* Build configuration list for PBXNativeTarget "KVConstraintExtensionsExample" */ = {
574 | isa = XCConfigurationList;
575 | buildConfigurations = (
576 | 04A1538A1B6FFBDD0004D1A9 /* Debug */,
577 | 04A1538B1B6FFBDD0004D1A9 /* Release */,
578 | );
579 | defaultConfigurationIsVisible = 0;
580 | defaultConfigurationName = Release;
581 | };
582 | 04A1538C1B6FFBDD0004D1A9 /* Build configuration list for PBXNativeTarget "KVConstraintExtensionsExampleTests" */ = {
583 | isa = XCConfigurationList;
584 | buildConfigurations = (
585 | 04A1538D1B6FFBDD0004D1A9 /* Debug */,
586 | 04A1538E1B6FFBDD0004D1A9 /* Release */,
587 | );
588 | defaultConfigurationIsVisible = 0;
589 | defaultConfigurationName = Release;
590 | };
591 | /* End XCConfigurationList section */
592 | };
593 | rootObject = 04A1534F1B6FFBDC0004D1A9 /* Project object */;
594 | }
595 |
--------------------------------------------------------------------------------