Skip to content

Commit

Permalink
AlignAboveWithLeftPadding, AlignAboveWidthRightPadding
Browse files Browse the repository at this point in the history
  • Loading branch information
Montak Oleg committed Oct 13, 2015
1 parent 27a41ae commit 4f80f39
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Facade/UIView+Facade.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@

#pragma mark - Above

- (void)alignAbove:(UIView *)view withLeftPadding:(CGFloat)left bottomPadding:(CGFloat)bottom width:(CGFloat)width height:(CGFloat)height;
- (void)alignAbove:(UIView *)view withRightPadding:(CGFloat)right bottomPadding:(CGFloat)bottom width:(CGFloat)width height:(CGFloat)height;
- (void)alignAbove:(UIView *)view matchingLeftWithBottomPadding:(CGFloat)bottom width:(CGFloat)width height:(CGFloat)height;
- (void)alignAbove:(UIView *)view matchingLeftAndFillingWidthWithRightPadding:(CGFloat)right bottomPadding:(CGFloat)bottom height:(CGFloat)height;
- (void)alignAbove:(UIView *)view matchingCenterWithBottomPadding:(CGFloat)bottom width:(CGFloat)width height:(CGFloat)height;
Expand Down
9 changes: 9 additions & 0 deletions Facade/UIView+Facade.m
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,17 @@ - (void)alignUnder:(UIView *)view matchingLeftAndRightWithTopPadding:(CGFloat)to
self.frame = CGRectMake(CGRectGetMinX(view.frame), CGRectGetMaxY(view.frame) + top, CGRectGetWidth(view.frame), height);
}


#pragma mark - Above

- (void)alignAbove:(UIView *)view withLeftPadding:(CGFloat)left bottomPadding:(CGFloat)bottom width:(CGFloat)width height:(CGFloat)height {
self.frame = CGRectMake(left, CGRectGetMinY(view.frame) - height - bottom, width, height);
}

- (void)alignAbove:(UIView *)view withRightPadding:(CGFloat)right bottomPadding:(CGFloat)bottom width:(CGFloat)width height:(CGFloat)height {
self.frame = CGRectMake(CGRectGetMaxX(self.superview.frame) - width - right, CGRectGetMinY(view.frame) - height - bottom, width, height);
}

- (void)alignAbove:(UIView *)view matchingLeftWithBottomPadding:(CGFloat)bottom width:(CGFloat)width height:(CGFloat)height {
self.frame = CGRectMake(CGRectGetMinX(view.frame), CGRectGetMinY(view.frame) - height - bottom, width, height);
}
Expand Down
12 changes: 12 additions & 0 deletions FacadeTests/FacadeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,18 @@ - (void)testAlignUnderMatchingLeftAndRightWithTopPadding {

#pragma mark - Above

- (void)testAlignAboveWithLeftPadding {
[_candidateView alignAbove:_siblingView withLeftPadding:10 bottomPadding:20 width:50 height:100];

XCTAssertTrue(CGRectEqualToRect(_candidateView.frame, CGRectMake(10, 180, 50, 100)));
}

- (void)testAlignAboveWithRightPadding {
[_candidateView alignAbove:_siblingView withRightPadding:20 bottomPadding:50 width:30 height:80];

XCTAssertTrue(CGRectEqualToRect(_candidateView.frame, CGRectMake(950, 170, 30, 80)));
}

- (void)testAlignAboveMatchingLeft {
[_candidateView alignAbove:_siblingView matchingLeftWithBottomPadding:10 width:40 height:100];

Expand Down

0 comments on commit 4f80f39

Please sign in to comment.