Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ios
/
Masonry
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Nikolay Tymchenko
11 years ago
Commit
2438fe90d769ff53646c12ee89aef4ef5c1f847a
1 parent
1a577997
Unprefix _equalToWithRelation and _valueOffset
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
27 deletions
Masonry/MASCompositeConstraint.m
Masonry/MASConstraint+Private.h
Masonry/MASConstraint.h
Masonry/MASConstraint.m
Masonry/MASViewConstraint.m
Masonry/MASCompositeConstraint.m
View file @
2438fe9
...
...
@@ -69,12 +69,12 @@
};
}
#pragma mark - NSLayoutRelation prox
ies
#pragma mark - NSLayoutRelation prox
y
-
(
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
;
};
...
...
Masonry/MASConstraint+Private.h
View file @
2438fe9
...
...
@@ -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
>
/**
...
...
Masonry/MASConstraint.h
View file @
2438fe9
...
...
@@ -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
;
...
...
Masonry/MASConstraint.m
View file @
2438fe9
...
...
@@ -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
();
}
...
...
Masonry/MASViewConstraint.m
View file @
2438fe9
...
...
@@ -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"
);
...
...
Please
register
or
login
to post a comment