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
Jonas Budelmann
12 years ago
Commit
fc50134f7bb247b0825ab0d62673939bfe6a906e
1 parent
57c125a6
change multiplier syntax
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
10 deletions
Masonry/MASCompositeConstraint.m
Masonry/MASConstraint.h
Masonry/MASViewConstraint.m
MasonryTests/MASViewConstraintSpec.m
Masonry/MASCompositeConstraint.m
View file @
fc50134
...
...
@@ -127,10 +127,19 @@
#pragma mark - NSLayoutConstraint multiplier proxies
-
(
id
<
MASConstraint
>
(
^
)(
CGFloat
))
percent
{
return
^
id
(
CGFloat
percent
)
{
-
(
id
<
MASConstraint
>
(
^
)(
CGFloat
))
multipliedBy
{
return
^
id
(
CGFloat
multiplier
)
{
for
(
id
<
MASConstraint
>
constraint
in
self
.
childConstraints
)
{
constraint
.
percent
(
percent
);
constraint
.
multipliedBy
(
multiplier
);
}
return
self
;
};
}
-
(
id
<
MASConstraint
>
(
^
)(
CGFloat
))
dividedBy
{
return
^
id
(
CGFloat
divider
)
{
for
(
id
<
MASConstraint
>
constraint
in
self
.
childConstraints
)
{
constraint
.
dividedBy
(
divider
);
}
return
self
;
};
...
...
Masonry/MASConstraint.h
View file @
fc50134
...
...
@@ -52,7 +52,12 @@
/**
* Sets the NSLayoutConstraint multiplier property
*/
@property
(
nonatomic
,
copy
,
readonly
)
id
<
MASConstraint
>
(
^
percent
)(
CGFloat
percent
);
@property
(
nonatomic
,
copy
,
readonly
)
id
<
MASConstraint
>
(
^
multipliedBy
)(
CGFloat
multiplier
);
/**
* Sets the NSLayoutConstraint multiplier to 1.0/dividedBy
*/
@property
(
nonatomic
,
copy
,
readonly
)
id
<
MASConstraint
>
(
^
dividedBy
)(
CGFloat
divider
);
/**
* Sets the NSLayoutConstraint priority to a float or MASLayoutPriority
...
...
Masonry/MASViewConstraint.m
View file @
fc50134
...
...
@@ -148,12 +148,23 @@
#pragma mark - NSLayoutConstraint multiplier proxies
-
(
id
<
MASConstraint
>
(
^
)(
CGFloat
))
percent
{
return
^
id
(
CGFloat
percent
)
{
-
(
id
<
MASConstraint
>
(
^
)(
CGFloat
))
multipliedBy
{
return
^
id
(
CGFloat
multiplier
)
{
NSAssert
(
!
self
.
hasBeenInstalled
,
@"Cannot modify constraint
percent
after it has been installed"
);
@"Cannot modify constraint
multiplier
after it has been installed"
);
self
.
layoutMultiplier
=
percent
;
self
.
layoutMultiplier
=
multiplier
;
return
self
;
};
}
-
(
id
<
MASConstraint
>
(
^
)(
CGFloat
))
dividedBy
{
return
^
id
(
CGFloat
divider
)
{
NSAssert
(
!
self
.
hasBeenInstalled
,
@"Cannot modify constraint multiplier after it has been installed"
);
self
.
layoutMultiplier
=
1
.
0
/
divider
;
return
self
;
};
}
...
...
MasonryTests/MASViewConstraintSpec.m
View file @
fc50134
...
...
@@ -157,7 +157,7 @@ describe(@"multiplier & constant", ^{
[
constraint
install
];
expect
(
^
{
constraint
.
percent
(
0
.
9
);
constraint
.
multipliedBy
(
0
.
9
);
}).
to
.
raise
(
@"NSInternalInconsistencyException"
);
});
...
...
@@ -225,7 +225,7 @@ describe(@"install", ^{
it
(
@"should create layout constraint on commit"
,
^
{
MASViewAttribute
*
secondViewAttribute
=
otherView
.
mas_height
;
constraint
.
equalTo
(
secondViewAttribute
);
constraint
.
percent
(
0
.
5
);
constraint
.
multipliedBy
(
0
.
5
);
constraint
.
offset
(
10
);
constraint
.
priority
(
345
);
[
constraint
install
];
...
...
Please
register
or
login
to post a comment