forked from jrturton/UIView-Autolayout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUIView+AutoLayout.h
57 lines (43 loc) · 2.95 KB
/
UIView+AutoLayout.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
56
57
//
// UIView+AutoLayout.h
// CollectionTableGrid
//
// Created by Richard Turton on 18/10/2012.
// Copyright (c) 2012 Richard Turton. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef NS_OPTIONS(unsigned long, JRTViewPinEdges){
JRTViewPinTopEdge = 1 << 0,
JRTViewPinRightEdge = 1 << 1,
JRTViewPinBottomEdge = 1 << 2,
JRTViewPinLeftEdge = 1 << 3,
JRTViewPinAllEdges = ~0UL
};
@interface UIView (AutoLayout)
/// Return a frameless view that does not automatically use autoresizing (for use in autolayouts)
+(id)autoLayoutView;
/// Centers the receiver in the superview
-(NSArray *)centerInView:(UIView*)superview;
-(NSLayoutConstraint *)centerInContainerOnAxis:(NSLayoutAttribute)axis;
/// Pin an attribute to the same attribute on another view. Both views must be in the same view hierarchy
-(NSLayoutConstraint *)pinAttribute:(NSLayoutAttribute)attribute toSameAttributeOfView:(UIView *)peerView;
/// Pin an attribute to the same attribute on another view along with a multiplier. Both views must be in the same view hierarchy
-(NSLayoutConstraint *)pinAttribute:(NSLayoutAttribute)attribute toSameAttributeOfView:(UIView *)peerView withMultiplier:(CGFloat)multiplier;
/// Pin an attribute to the same attribute on another view along with a constant. Both views must be in the same view hierarchy
-(NSLayoutConstraint *)pinAttribute:(NSLayoutAttribute)attribute toSameAttributeOfView:(UIView *)peerView withConstant:(CGFloat)constant;
/// Pins a view to a specific edge(s) of its superview, with a specified inset
-(NSArray*)pinToSuperviewEdges:(JRTViewPinEdges)edges inset:(CGFloat)inset;
/// Pins a view to all edges of its superview, with specified edge insets
-(NSArray*)pinToSuperviewEdgesWithInset:(UIEdgeInsets)insets;
/// Pins a view's edge to a peer view's edge. Both views must be in the same view hierarchy
-(NSLayoutConstraint *)pinEdge:(NSLayoutAttribute)edge toEdge:(NSLayoutAttribute)toEdge ofView:(UIView*)peerView;
-(NSLayoutConstraint *)pinEdge:(NSLayoutAttribute)edge toEdge:(NSLayoutAttribute)toEdge ofView:(UIView *)peerView inset:(CGFloat)inset;
/// Set to a specific size. 0 in any axis results in no constraint being applied.
-(NSArray *)constrainToSize:(CGSize)size;
/// Pins a point to a specific point in the superview's frame. Use NSLayoutAttributeNotAnAttribute to only pin in one dimension
-(void)pinPointAtX:(NSLayoutAttribute)x Y:(NSLayoutAttribute)y toPoint:(CGPoint)point;
/// Spaces the views evenly along the selected axis. Will force the views to the same size to make them fit
-(void)spaceViews:(NSArray*)views onAxis:(UILayoutConstraintAxis)axis withSpacing:(CGFloat)spacing alignmentOptions:(NSLayoutFormatOptions)options;
/// Spaces the views evenly along the selected axis. Will force the views to the same size to make them fit within the view and inset.
-(void)spaceViews:(NSArray*)views onAxis:(UILayoutConstraintAxis)axis withSpacing:(CGFloat)spacing withInset:(CGFloat)inset alignmentOptions:(NSLayoutFormatOptions)options;
@end