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
Plain Diff
Browse Files
Authored by
Robert Payne
8 years ago
Committed by
GitHub
8 years ago
Commit
7a59f9c3ef0ff1ff2213bba2e23f955d7a733a73
2 parents
375d9a5e
65244f96
Merge pull request #388 from iwill/master
Added inset property
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
1 deletions
Masonry/MASCompositeConstraint.m
Masonry/MASConstraint.h
Masonry/MASConstraint.m
Masonry/MASViewConstraint.m
Tests/Specs/MASCompositeConstraintSpec.m
Masonry/MASCompositeConstraint.m
View file @
7a59f9c
...
...
@@ -129,6 +129,12 @@
}
}
-
(
void
)
setInset
:
(
CGFloat
)
inset
{
for
(
MASConstraint
*
constraint
in
self
.
childConstraints
)
{
constraint
.
inset
=
inset
;
}
}
-
(
void
)
setOffset
:
(
CGFloat
)
offset
{
for
(
MASConstraint
*
constraint
in
self
.
childConstraints
)
{
constraint
.
offset
=
offset
;
...
...
Masonry/MASConstraint.h
View file @
7a59f9c
...
...
@@ -27,6 +27,13 @@
/**
* Modifies the NSLayoutConstraint constant,
* only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
* NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
*/
-
(
MASConstraint
*
(
^
)(
CGFloat
inset
))
inset
;
/**
* Modifies the NSLayoutConstraint constant,
* only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
* NSLayoutAttributeWidth, NSLayoutAttributeHeight
*/
-
(
MASConstraint
*
(
^
)(
CGSize
offset
))
sizeOffset
;
...
...
@@ -166,6 +173,13 @@
/**
* Modifies the NSLayoutConstraint constant,
* only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
* NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
*/
-
(
void
)
setInset
:(
CGFloat
)
inset
;
/**
* Modifies the NSLayoutConstraint constant,
* only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
* NSLayoutAttributeWidth, NSLayoutAttributeHeight
*/
-
(
void
)
setSizeOffset
:(
CGSize
)
sizeOffset
;
...
...
Masonry/MASConstraint.m
View file @
7a59f9c
...
...
@@ -92,6 +92,13 @@
};
}
-
(
MASConstraint
*
(
^
)(
CGFloat
))
inset
{
return
^
id
(
CGFloat
inset
){
self
.
inset
=
inset
;
return
self
;
};
}
-
(
MASConstraint
*
(
^
)(
CGSize
))
sizeOffset
{
return
^
id
(
CGSize
offset
)
{
self
.
sizeOffset
=
offset
;
...
...
@@ -269,6 +276,8 @@
-
(
void
)
setInsets
:
(
MASEdgeInsets
__unused
)
insets
{
MASMethodNotImplemented
();
}
-
(
void
)
setInset
:
(
CGFloat
__unused
)
inset
{
MASMethodNotImplemented
();
}
-
(
void
)
setSizeOffset
:
(
CGSize
__unused
)
sizeOffset
{
MASMethodNotImplemented
();
}
-
(
void
)
setCenterOffset
:
(
CGPoint
__unused
)
centerOffset
{
MASMethodNotImplemented
();
}
...
...
Masonry/MASViewConstraint.m
View file @
7a59f9c
...
...
@@ -254,6 +254,10 @@ static char kInstalledConstraintsKey;
}
}
-
(
void
)
setInset
:
(
CGFloat
)
inset
{
[
self
setInsets
:(
MASEdgeInsets
){.
top
=
inset
,
.
left
=
inset
,
.
bottom
=
inset
,
.
right
=
inset
}];
}
-
(
void
)
setOffset
:
(
CGFloat
)
offset
{
self
.
layoutConstant
=
offset
;
}
...
...
Tests/Specs/MASCompositeConstraintSpec.m
View file @
7a59f9c
...
...
@@ -133,6 +133,28 @@ SpecBegin(MASCompositeConstraint) {
expect
([
children
[
5
]
layoutConstant
]).
to
.
equal
(
0
);
};
-
(
void
)
testModifyInsetOnAppropriateChildren
{
NSArray
*
children
=
@[
[[
MASViewConstraint
alloc
]
initWithFirstViewAttribute
:
view
.
mas_right
],
[[
MASViewConstraint
alloc
]
initWithFirstViewAttribute
:
view
.
mas_top
],
[[
MASViewConstraint
alloc
]
initWithFirstViewAttribute
:
view
.
mas_bottom
],
[[
MASViewConstraint
alloc
]
initWithFirstViewAttribute
:
view
.
mas_left
],
[[
MASViewConstraint
alloc
]
initWithFirstViewAttribute
:
view
.
mas_baseline
],
[[
MASViewConstraint
alloc
]
initWithFirstViewAttribute
:
view
.
mas_width
],
];
composite
=
[[
MASCompositeConstraint
alloc
]
initWithChildren
:
children
];
composite
.
delegate
=
delegate
;
composite
.
with
.
inset
(
1
);
expect
([
children
[
0
]
layoutConstant
]).
to
.
equal
(
-
1
);
expect
([
children
[
1
]
layoutConstant
]).
to
.
equal
(
1
);
expect
([
children
[
2
]
layoutConstant
]).
to
.
equal
(
-
1
);
expect
([
children
[
3
]
layoutConstant
]).
to
.
equal
(
1
);
expect
([
children
[
4
]
layoutConstant
]).
to
.
equal
(
0
);
expect
([
children
[
5
]
layoutConstant
]).
to
.
equal
(
0
);
};
-
(
void
)
testUninstall
{
NSArray
*
children
=
@[
[[
MASViewConstraint
alloc
]
initWithFirstViewAttribute
:
view
.
mas_leading
],
...
...
@@ -193,4 +215,4 @@ SpecBegin(MASCompositeConstraint) {
expect
(
newChild
.
delegate
).
to
.
beIdenticalTo
(
composite
);
}
SpecEnd
\ No newline at end of file
SpecEnd
...
...
Please
register
or
login
to post a comment