Skip to content

Commit

Permalink
support safeAreaLayoutGuide - rename
Browse files Browse the repository at this point in the history
  • Loading branch information
iwill committed Sep 27, 2017
1 parent a2f1d06 commit 53a095b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,66 +54,66 @@ - (void)viewDidLoad {
const CGFloat size = 50.0;

[view1 mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view.mas_safeArea).inset(10.0);
make.edges.equalTo(self.view.mas_safeAreaLayoutGuide).inset(10.0);
}];

[view2 mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self.view.mas_safeArea);
make.width.height.equalTo(self.view.mas_safeArea).sizeOffset(CGSizeMake(- 40.0, - 40.0));
make.center.equalTo(self.view.mas_safeAreaLayoutGuide);
make.width.height.equalTo(self.view.mas_safeAreaLayoutGuide).sizeOffset(CGSizeMake(- 40.0, - 40.0));
}];

[view3 mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self.view.mas_safeArea);
make.width.equalTo(self.view.mas_safeArea).sizeOffset(CGSizeMake(- 60.0, - 60.0));
make.height.equalTo(self.view.mas_safeArea).sizeOffset(CGSizeMake(- 60.0, - 60.0));
make.center.equalTo(self.view.mas_safeAreaLayoutGuide);
make.width.equalTo(self.view.mas_safeAreaLayoutGuide).sizeOffset(CGSizeMake(- 60.0, - 60.0));
make.height.equalTo(self.view.mas_safeAreaLayoutGuide).sizeOffset(CGSizeMake(- 60.0, - 60.0));
}];

[leftTopView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.equalTo(self.view.mas_safeArea);
make.left.top.equalTo(self.view.mas_safeAreaLayoutGuide);
make.width.height.equalTo(@(size));
}];

[rightTopView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.view.mas_safeAreaRight);
make.top.equalTo(self.view.mas_safeAreaTop);
make.right.equalTo(self.view.mas_safeAreaLayoutGuideRight);
make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
make.width.height.equalTo(@(size));
}];

[leftBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view.mas_safeAreaLeft);
make.bottom.equalTo(self.view.mas_safeAreaBottom);
make.left.equalTo(self.view.mas_safeAreaLayoutGuideLeft);
make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
make.width.height.equalTo(@(size));
}];

[rightBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.bottom.equalTo(self.view.mas_safeArea);
make.right.bottom.equalTo(self.view.mas_safeAreaLayoutGuide);
make.width.height.equalTo(@(size));
}];

[leftView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.centerY.equalTo(self.view.mas_safeArea);
make.left.centerY.equalTo(self.view.mas_safeAreaLayoutGuide);
make.width.height.equalTo(@(size));
}];

[rightView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.view.mas_safeAreaRight);
make.centerY.equalTo(self.view.mas_safeAreaCenterY);
make.right.equalTo(self.view.mas_safeAreaLayoutGuideRight);
make.centerY.equalTo(self.view.mas_safeAreaLayoutGuideCenterY);
make.width.height.equalTo(@(size));
}];

[topView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.view.mas_safeAreaTop);
make.centerX.equalTo(self.view.mas_safeAreaCenterX);
make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
make.centerX.equalTo(self.view.mas_safeAreaLayoutGuideCenterX);
make.width.height.equalTo(@(size));
}];

[bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.centerX.equalTo(self.view.mas_safeArea);
make.bottom.centerX.equalTo(self.view.mas_safeAreaLayoutGuide);
make.width.height.equalTo(@(size));
}];

[centerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self.view.mas_safeArea);
make.center.equalTo(self.view.mas_safeAreaLayoutGuide);
make.width.height.equalTo(@(size));
}];
}
Expand Down
30 changes: 12 additions & 18 deletions Masonry/View+MASAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,18 @@

#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || (__TV_OS_VERSION_MIN_REQUIRED >= 110000)

@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeArea;

@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLeading;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaTrailing;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLeft;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaRight;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaTop;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaBottom;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaWidth;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaHeight;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaCenterX;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaCenterY;

@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide DEPRECATED_ATTRIBUTE;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop DEPRECATED_ATTRIBUTE;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom DEPRECATED_ATTRIBUTE;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft DEPRECATED_ATTRIBUTE;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight DEPRECATED_ATTRIBUTE;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide;

@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeading;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTrailing;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideWidth;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideHeight;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideCenterX;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideCenterY;

#endif

Expand Down
42 changes: 11 additions & 31 deletions Masonry/View+MASAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,70 +136,50 @@ - (MASViewAttribute *)mas_centerYWithinMargins {

#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || (__TV_OS_VERSION_MIN_REQUIRED >= 110000)

#pragma mark - safeAreaLayoutGuide

- (MASViewAttribute *)mas_safeArea {
- (MASViewAttribute *)mas_safeAreaLayoutGuide {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeNotAnAttribute];
}

- (MASViewAttribute *)mas_safeAreaLeading {
- (MASViewAttribute *)mas_safeAreaLayoutGuideLeading {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeLeading];
}

- (MASViewAttribute *)mas_safeAreaTrailing {
- (MASViewAttribute *)mas_safeAreaLayoutGuideTrailing {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeTrailing];
}

- (MASViewAttribute *)mas_safeAreaLeft {
- (MASViewAttribute *)mas_safeAreaLayoutGuideLeft {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeLeft];
}

- (MASViewAttribute *)mas_safeAreaRight {
- (MASViewAttribute *)mas_safeAreaLayoutGuideRight {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeRight];
}

- (MASViewAttribute *)mas_safeAreaTop {
- (MASViewAttribute *)mas_safeAreaLayoutGuideTop {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeTop];
}

- (MASViewAttribute *)mas_safeAreaBottom {
- (MASViewAttribute *)mas_safeAreaLayoutGuideBottom {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
}

- (MASViewAttribute *)mas_safeAreaWidth {
- (MASViewAttribute *)mas_safeAreaLayoutGuideWidth {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeWidth];
}

- (MASViewAttribute *)mas_safeAreaHeight {
- (MASViewAttribute *)mas_safeAreaLayoutGuideHeight {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeHeight];
}

- (MASViewAttribute *)mas_safeAreaCenterX {
- (MASViewAttribute *)mas_safeAreaLayoutGuideCenterX {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeCenterX];
}

- (MASViewAttribute *)mas_safeAreaCenterY {
- (MASViewAttribute *)mas_safeAreaLayoutGuideCenterY {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeCenterY];
}

#pragma mark - DEPRECATED

- (MASViewAttribute *)mas_safeAreaLayoutGuide {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
}
- (MASViewAttribute *)mas_safeAreaLayoutGuideTop {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeTop];
}
- (MASViewAttribute *)mas_safeAreaLayoutGuideBottom {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
}
- (MASViewAttribute *)mas_safeAreaLayoutGuideLeft {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeLeft];
}
- (MASViewAttribute *)mas_safeAreaLayoutGuideRight {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeRight];
}

#endif

#pragma mark - associated properties
Expand Down

0 comments on commit 53a095b

Please sign in to comment.