Authored by Nikolay Tymchenko

Unprefix _equalToWithRelation and _valueOffset

... ... @@ -69,12 +69,12 @@
};
}
#pragma mark - NSLayoutRelation proxies
#pragma mark - NSLayoutRelation proxy
- (MASConstraint * (^)(id, NSLayoutRelation))_equalToWithRelation {
- (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation {
return ^id(id attr, NSLayoutRelation relation) {
for (MASConstraint *constraint in self.childConstraints.copy) {
constraint._equalToWithRelation(attr, relation);
constraint.equalToWithRelation(attr, relation);
}
return self;
};
... ...
... ... @@ -35,6 +35,19 @@
@end
@interface MASConstraint (Abstract)
/**
* Sets the constraint relation to given NSLayoutRelation
* returns a block which accepts one of the following:
* MASViewAttribute, UIView, NSValue, NSArray
* see readme for more details.
*/
- (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation;
@end
@protocol MASConstraintDelegate <NSObject>
/**
... ...
... ... @@ -44,6 +44,11 @@
- (MASConstraint * (^)(CGFloat offset))offset;
/**
* Modifies the NSLayoutConstraint constant based on a value type
*/
- (MASConstraint * (^)(NSValue *value))valueOffset;
/**
* Sets the NSLayoutConstraint multiplier property
*/
- (MASConstraint * (^)(CGFloat multiplier))multipliedBy;
... ... @@ -166,11 +171,11 @@
* Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax.
* A potential drawback of this is that the unprefixed macros will appear in global scope.
*/
#define mas_equalTo(...) _equalToWithRelation(MASBoxValue((__VA_ARGS__)), NSLayoutRelationEqual)
#define mas_greaterThanOrEqualTo(...) _equalToWithRelation(MASBoxValue((__VA_ARGS__)), NSLayoutRelationGreaterThanOrEqual)
#define mas_lessThanOrEqualTo(...) _equalToWithRelation(MASBoxValue((__VA_ARGS__)), NSLayoutRelationLessThanOrEqual)
#define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__)))
#define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__)))
#define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__)))
#define mas_offset(...) _valueOffset(MASBoxValue((__VA_ARGS__)))
#define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__)))
#ifdef MAS_SHORTHAND_GLOBALS
... ... @@ -187,19 +192,6 @@
@interface MASConstraint (AutoboxingSupport)
/**
* Modifies the NSLayoutConstraint constant based on a value type
*/
- (MASConstraint * (^)(id))_valueOffset;
/**
* Sets the constraint relation to given NSLayoutRelation
* returns a block which accepts one of the following:
* MASViewAttribute, UIView, NSValue, NSArray
* see readme for more details.
*/
- (MASConstraint * (^)(id attr, NSLayoutRelation relation))_equalToWithRelation;
/**
* Dummy methods to aid autocompletion
*/
- (MASConstraint * (^)(id attr))mas_equalTo;
... ...
... ... @@ -26,19 +26,19 @@
- (MASConstraint * (^)(id))equalTo {
return ^id(id attribute) {
return self._equalToWithRelation(attribute, NSLayoutRelationEqual);
return self.equalToWithRelation(attribute, NSLayoutRelationEqual);
};
}
- (MASConstraint * (^)(id))greaterThanOrEqualTo {
return ^id(id attribute) {
return self._equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual);
return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual);
};
}
- (MASConstraint * (^)(id))lessThanOrEqualTo {
return ^id(id attribute) {
return self._equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual);
return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual);
};
}
... ... @@ -95,8 +95,8 @@
};
}
- (MASConstraint * (^)(id))_valueOffset {
return ^id(id offset) {
- (MASConstraint * (^)(NSValue *value))valueOffset {
return ^id(NSValue *offset) {
NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset);
[self setLayoutConstantWithValue:offset];
return self;
... ... @@ -149,7 +149,7 @@
- (MASConstraint * (^)(MASLayoutPriority priority))priority { methodNotImplemented(); }
- (MASConstraint * (^)(id, NSLayoutRelation))_equalToWithRelation { methodNotImplemented(); }
- (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { methodNotImplemented(); }
- (MASConstraint * (^)(id key))key { methodNotImplemented(); }
... ...
... ... @@ -126,7 +126,7 @@
#pragma mark - NSLayoutRelation proxy
- (MASConstraint * (^)(id, NSLayoutRelation))_equalToWithRelation {
- (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation {
return ^id(id attribute, NSLayoutRelation relation) {
if ([attribute isKindOfClass:NSArray.class]) {
NSAssert(!self.hasLayoutRelation, @"Redefinition of constraint relation");
... ...