-
Notifications
You must be signed in to change notification settings - Fork 3
/
UIView+Constraint.h
55 lines (42 loc) · 2.43 KB
/
UIView+Constraint.h
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// UIView+Constraint.h
//
// Created by FukuyamaShingo on 9/1/14.
// Copyright (c) 2014 ShingoFukuyama. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIView (Constraint)
/// Return an array of NSLayoutConstraint @[top, left, bottom, right]
- (NSArray *)addConstraintFill;
/// Return an array of NSLayoutConstraint @[top, left, bottom, right]
- (NSArray *)addConstraintFillWithInsets:(UIEdgeInsets)insets;
/// Return an array of NSLayoutConstraint @[top, bottom]
- (NSArray *)addConstraintFromTop:(CGFloat)top toBottom:(CGFloat)bottom;
/// Return an array of NSLayoutConstraint @[left, right]
- (NSArray *)addConstraintFromLeft:(CGFloat)left toRight:(CGFloat)right;
- (NSLayoutConstraint *)addConstraintFromTop:(CGFloat)distance;
- (NSLayoutConstraint *)addConstraintFromBottom:(CGFloat)distance;
- (NSLayoutConstraint *)addConstraintFromLeft:(CGFloat)distance;
- (NSLayoutConstraint *)addConstraintFromRight:(CGFloat)distance;
- (NSLayoutConstraint *)addConstraintWidth:(CGFloat)width;
- (NSLayoutConstraint *)addConstraintHeight:(CGFloat)height;
/// Return an array of NSLayoutConstraint @[width, height]
- (NSArray *)addConstraintWidth:(CGFloat)width height:(CGFloat)height;
- (NSLayoutConstraint *)addConstraintCenteringX;
- (NSLayoutConstraint *)addConstraintCenteringY;
/// Return an array of NSLayoutConstraint @[centerX, centerY]
- (NSArray *)addConstraintCenteringXY;
- (NSLayoutConstraint *)addConstraintCenteringXWithOffset:(CGFloat)offsetX;
- (NSLayoutConstraint *)addConstraintCenteringYWithOffset:(CGFloat)offsetY;
/// Return an array of NSLayoutConstraint @[centerX, centerY]
- (NSArray *)addConstraintCenteringXYWithOffset:(UIOffset)offset;
- (NSLayoutConstraint *)addConstraintFromViewTop:(UIView *)fromView distance:(CGFloat)distance;
- (NSLayoutConstraint *)addConstraintFromViewBottom:(UIView *)fromView distance:(CGFloat)distance;
- (NSLayoutConstraint *)addConstraintFromViewLeft:(UIView *)fromView distance:(CGFloat)distance;
- (NSLayoutConstraint *)addConstraintFromViewRight:(UIView *)fromView distance:(CGFloat)distance;
- (NSLayoutConstraint *)addConstraintAlignViewTop:(UIView *)baseView offset:(CGFloat)offset;
- (NSLayoutConstraint *)addConstraintAlignViewBottom:(UIView *)baseView offset:(CGFloat)offset;
- (NSLayoutConstraint *)addConstraintAlignViewLeft:(UIView *)baseView offset:(CGFloat)offset;
- (NSLayoutConstraint *)addConstraintAlignViewRight:(UIView *)baseView offset:(CGFloat)offset;
- (void)removeAllConstraints;
@end