Authored by iwill

support safeAreaLayoutGuide

@@ -125,7 +125,12 @@ static char kInstalledConstraintsKey; @@ -125,7 +125,12 @@ static char kInstalledConstraintsKey;
125 } else if ([secondViewAttribute isKindOfClass:MAS_VIEW.class]) { 125 } else if ([secondViewAttribute isKindOfClass:MAS_VIEW.class]) {
126 _secondViewAttribute = [[MASViewAttribute alloc] initWithView:secondViewAttribute layoutAttribute:self.firstViewAttribute.layoutAttribute]; 126 _secondViewAttribute = [[MASViewAttribute alloc] initWithView:secondViewAttribute layoutAttribute:self.firstViewAttribute.layoutAttribute];
127 } else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) { 127 } else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) {
128 - _secondViewAttribute = secondViewAttribute; 128 + MASViewAttribute *attr = secondViewAttribute;
  129 + if (attr.layoutAttribute == NSLayoutAttributeNotAnAttribute) {
  130 + _secondViewAttribute = [[MASViewAttribute alloc] initWithView:attr.view item:attr.item layoutAttribute:self.firstViewAttribute.layoutAttribute];;
  131 + } else {
  132 + _secondViewAttribute = secondViewAttribute;
  133 + }
129 } else { 134 } else {
130 NSAssert(NO, @"attempting to add unsupported attribute: %@", secondViewAttribute); 135 NSAssert(NO, @"attempting to add unsupported attribute: %@", secondViewAttribute);
131 } 136 }
@@ -54,11 +54,24 @@ @@ -54,11 +54,24 @@
54 54
55 #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || (__TV_OS_VERSION_MIN_REQUIRED >= 110000) 55 #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || (__TV_OS_VERSION_MIN_REQUIRED >= 110000)
56 56
57 -@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide;  
58 -@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop;  
59 -@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom;  
60 -@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft;  
61 -@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight; 57 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeArea;
  58 +
  59 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLeading;
  60 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaTrailing;
  61 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLeft;
  62 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaRight;
  63 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaTop;
  64 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaBottom;
  65 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaWidth;
  66 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaHeight;
  67 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaCenterX;
  68 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaCenterY;
  69 +
  70 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide DEPRECATED_ATTRIBUTE;
  71 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop DEPRECATED_ATTRIBUTE;
  72 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom DEPRECATED_ATTRIBUTE;
  73 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft DEPRECATED_ATTRIBUTE;
  74 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight DEPRECATED_ATTRIBUTE;
62 75
63 #endif 76 #endif
64 77
@@ -136,6 +136,54 @@ @@ -136,6 +136,54 @@
136 136
137 #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || (__TV_OS_VERSION_MIN_REQUIRED >= 110000) 137 #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || (__TV_OS_VERSION_MIN_REQUIRED >= 110000)
138 138
  139 +#pragma mark - safeAreaLayoutGuide
  140 +
  141 +- (MASViewAttribute *)mas_safeArea {
  142 + return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeNotAnAttribute];
  143 +}
  144 +
  145 +- (MASViewAttribute *)mas_safeAreaLeading {
  146 + return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeLeading];
  147 +}
  148 +
  149 +- (MASViewAttribute *)mas_safeAreaTrailing {
  150 + return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeTrailing];
  151 +}
  152 +
  153 +- (MASViewAttribute *)mas_safeAreaLeft {
  154 + return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeLeft];
  155 +}
  156 +
  157 +- (MASViewAttribute *)mas_safeAreaRight {
  158 + return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeRight];
  159 +}
  160 +
  161 +- (MASViewAttribute *)mas_safeAreaTop {
  162 + return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeTop];
  163 +}
  164 +
  165 +- (MASViewAttribute *)mas_safeAreaBottom {
  166 + return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
  167 +}
  168 +
  169 +- (MASViewAttribute *)mas_safeAreaWidth {
  170 + return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeWidth];
  171 +}
  172 +
  173 +- (MASViewAttribute *)mas_safeAreaHeight {
  174 + return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeHeight];
  175 +}
  176 +
  177 +- (MASViewAttribute *)mas_safeAreaCenterX {
  178 + return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeCenterX];
  179 +}
  180 +
  181 +- (MASViewAttribute *)mas_safeAreaCenterY {
  182 + return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeCenterY];
  183 +}
  184 +
  185 +#pragma mark - DEPRECATED
  186 +
139 - (MASViewAttribute *)mas_safeAreaLayoutGuide { 187 - (MASViewAttribute *)mas_safeAreaLayoutGuide {
140 return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 188 return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
141 } 189 }