-
Notifications
You must be signed in to change notification settings - Fork 0
/
NSLayoutConstraint+BDKGeometry.m
24 lines (19 loc) · 1.21 KB
/
NSLayoutConstraint+BDKGeometry.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
#import "NSLayoutConstraint+BDKGeometry.h"
@implementation NSLayoutConstraint (BDKGeometry)
+ (NSArray *)constraintsAligningCenterOfView:(UIView *)view withSuperview:(UIView *)superview {
return @[[self constraintAligningHorizontalCenterOfView:view withSuperview:superview],
[self constraintAligningVerticalCenterOfView:view withSuperview:superview]];
}
+ (instancetype)constraintAligningHorizontalCenterOfView:(UIView *)view withSuperview:(UIView *)superview {
return [NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:superview attribute:NSLayoutAttributeCenterX
multiplier:1 constant:0];
}
+ (instancetype)constraintAligningVerticalCenterOfView:(UIView *)view withSuperview:(UIView *)superview {
return [NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:superview attribute:NSLayoutAttributeCenterY
multiplier:1 constant:0];
}
@end