Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
211361da
Commit
211361da
authored
Aug 30, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added default values to Layout
parent
24aaafba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
Source/Layout.swift
+10
-10
No files found.
Source/Layout.swift
View file @
211361da
...
...
@@ -22,7 +22,7 @@ public struct Layout {
/**
:name: width
*/
public
static
func
width
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
)
{
public
static
func
width
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
=
0
)
{
let
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"width"
:
width
]
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:[child(width)]"
,
options
:
nil
,
metrics
:
metrics
,
views
:
views
))
...
...
@@ -31,7 +31,7 @@ public struct Layout {
/**
:name: height
*/
public
static
func
height
(
parent
:
UIView
,
child
:
UIView
,
height
:
CGFloat
)
{
public
static
func
height
(
parent
:
UIView
,
child
:
UIView
,
height
:
CGFloat
=
0
)
{
let
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"height"
:
height
]
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"V:[child(height)]"
,
options
:
nil
,
metrics
:
metrics
,
views
:
views
))
...
...
@@ -40,7 +40,7 @@ public struct Layout {
/**
:name: size
*/
public
static
func
size
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
,
height
:
CGFloat
)
{
public
static
func
size
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
=
0
,
height
:
CGFloat
=
0
)
{
Layout
.
width
(
parent
,
child
:
child
,
width
:
width
)
Layout
.
height
(
parent
,
child
:
child
,
height
:
height
)
}
...
...
@@ -57,21 +57,21 @@ public struct Layout {
/**
:name: expandToParentHorizontallyWithPad
*/
public
static
func
expandToParentHorizontallyWithPad
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
,
right
:
CGFloat
)
{
public
static
func
expandToParentHorizontallyWithPad
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
{
parent
.
addConstraints
(
constraint
(
"H:|-(left)-[child]-(right)-|"
,
options
:
nil
,
metrics
:
[
"left"
:
left
,
"right"
:
right
],
views
:
[
"child"
:
child
]))
}
/**
:name: expandToParentVerticallyWithPad
*/
public
static
func
expandToParentVerticallyWithPad
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
,
bottom
:
CGFloat
)
{
public
static
func
expandToParentVerticallyWithPad
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
)
{
parent
.
addConstraints
(
constraint
(
"V:|-(top)-[child]-(bottom)-|"
,
options
:
nil
,
metrics
:
[
"bottom"
:
bottom
,
"top"
:
top
],
views
:
[
"child"
:
child
]))
}
/**
:name: expandToParentWithPad
*/
public
static
func
expandToParentWithPad
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
,
bottom
:
CGFloat
,
right
:
CGFloat
,
top
:
CGFloat
)
{
public
static
func
expandToParentWithPad
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
top
:
CGFloat
=
0
)
{
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:|-(left)-[child]-(right)-|"
,
options
:
nil
,
metrics
:
[
"left"
:
left
,
"right"
:
right
],
views
:
views
))
parent
.
addConstraints
(
constraint
(
"V:|-(top)-[child]-(bottom)-|"
,
options
:
nil
,
metrics
:
[
"bottom"
:
bottom
,
"top"
:
top
],
views
:
views
))
...
...
@@ -80,7 +80,7 @@ public struct Layout {
/**
:name: alignFromTopLeft
*/
public
static
func
alignFromTopLeft
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
,
left
:
CGFloat
)
{
public
static
func
alignFromTopLeft
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
)
{
let
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"top"
:
top
,
"left"
:
left
]
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:|-(left)-[child]"
,
options
:
nil
,
metrics
:
metrics
,
views
:
views
))
...
...
@@ -90,7 +90,7 @@ public struct Layout {
/**
:name: alignFromTopRight
*/
public
static
func
alignFromTopRight
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
,
right
:
CGFloat
)
{
public
static
func
alignFromTopRight
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
{
let
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"top"
:
top
,
"right"
:
right
]
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:[child]-(right)-|"
,
options
:
nil
,
metrics
:
metrics
,
views
:
views
))
...
...
@@ -100,7 +100,7 @@ public struct Layout {
/**
:name: alignFromBottomLeft
*/
public
static
func
alignFromBottomLeft
(
parent
:
UIView
,
child
:
UIView
,
bottom
:
CGFloat
,
left
:
CGFloat
)
{
public
static
func
alignFromBottomLeft
(
parent
:
UIView
,
child
:
UIView
,
bottom
:
CGFloat
=
0
,
left
:
CGFloat
=
0
)
{
let
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"bottom"
:
bottom
,
"left"
:
left
]
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:|-(left)-[child]"
,
options
:
nil
,
metrics
:
metrics
,
views
:
views
))
...
...
@@ -110,7 +110,7 @@ public struct Layout {
/**
:name: alignFromBottomRight
*/
public
static
func
alignFromBottomRight
(
parent
:
UIView
,
child
:
UIView
,
bottom
:
CGFloat
,
right
:
CGFloat
)
{
public
static
func
alignFromBottomRight
(
parent
:
UIView
,
child
:
UIView
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
{
let
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"bottom"
:
bottom
,
"right"
:
right
]
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:[child]-(right)-|"
,
options
:
nil
,
metrics
:
metrics
,
views
:
views
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment