Skip to content

Commit

Permalink
Merge 352056a into 6d169a8
Browse files Browse the repository at this point in the history
  • Loading branch information
MontakOleg committed Oct 2, 2015
2 parents 6d169a8 + 352056a commit cf57e82
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions Facade/UIView+Facade.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#pragma mark - Fill superview

- (void)fillSuperview;
- (void)fillSuperviewWithLeftPadding:(CGFloat)left rightPadding:(CGFloat)right topPadding:(CGFloat)top bottomPadding:(CGFloat)bottom;


#pragma mark - Corner alignment
Expand Down
7 changes: 7 additions & 0 deletions Facade/UIView+Facade.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ - (void)fillSuperview {
self.frame = CGRectMake(0, 0, CGRectGetWidth(self.superview.frame), CGRectGetHeight(self.superview.frame));
}

- (void)fillSuperviewWithLeftPadding:(CGFloat)left rightPadding:(CGFloat)right topPadding:(CGFloat)top bottomPadding:(CGFloat)bottom {
CGFloat width = CGRectGetWidth(self.superview.frame) - (left + right);
CGFloat height = CGRectGetHeight(self.superview.frame) - (top + bottom);

self.frame = CGRectMake(left, top, width, height);
}

#pragma mark - Corner alignment

- (void)anchorTopLeftWithLeftPadding:(CGFloat)left topPadding:(CGFloat)top width:(CGFloat)width height:(CGFloat)height {
Expand Down
6 changes: 6 additions & 0 deletions FacadeTests/FacadeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ - (void)testFillSuperview {
XCTAssertTrue(CGRectEqualToRect(_candidateView.frame, CGRectMake(0, 0, 1000, 1000)));
}

- (void)testFillSuperViewWithPaddings {
[_candidateView fillSuperviewWithLeftPadding:10 rightPadding:20 topPadding:30 bottomPadding:40];

XCTAssertTrue(CGRectEqualToRect(_candidateView.frame, CGRectMake(10, 30, 970, 930)));
}


#pragma mark - Corner alignment

Expand Down

0 comments on commit cf57e82

Please sign in to comment.