-
Notifications
You must be signed in to change notification settings - Fork 0
/
UIView+PCAutolayoutBindingExtensions.m
41 lines (37 loc) · 1.59 KB
/
UIView+PCAutolayoutBindingExtensions.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// UIView+PCAutolayoutBindingExtensions.m
// PCAutolayout
//
// Created by Patrick Perini on 8/14/13.
// Copyright (c) 2013 pcperini. All rights reserved.
//
#import "UIView+PCAutolayoutBindingExtensions.h"
@implementation UIView (PCAutolayoutBindingExtensions)
#pragma mark - Binding Mutators
- (void)addConstraintBindingToView:(UIView *)view onAttribute:(NSLayoutAttribute)attribute
{
NSLayoutConstraint *newConstraint;
if ([self isDescendantOfView: view])
{
newConstraint = [NSLayoutConstraint constraintWithItem: view
attribute: attribute
relatedBy: NSLayoutRelationEqual
toItem: self
attribute: attribute
multiplier: 1.0
constant: 0.0];
[view addConstraint: newConstraint];
}
else
{
newConstraint = [NSLayoutConstraint constraintWithItem: self
attribute: attribute
relatedBy: NSLayoutRelationEqual
toItem: view
attribute: attribute
multiplier: 1.0
constant: 0.0];
[self addConstraint: newConstraint];
}
}
@end