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
09cdb27c
Unverified
Commit
09cdb27c
authored
Sep 14, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: updated SwitchControl to Switch
parent
412c2ca7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
204 additions
and
263 deletions
+204
-263
Sources/iOS/Layout.swift
+129
-188
Sources/iOS/Switch.swift
+75
-75
No files found.
Sources/iOS/Layout.swift
View file @
09cdb27c
...
@@ -81,87 +81,81 @@ public class Layout {
...
@@ -81,87 +81,81 @@ public class Layout {
Sets the width of a view.
Sets the width of a view.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter width: A CGFloat value.
- Parameter width: A CGFloat value.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
width
(
_
child
:
UIView
,
width
:
CGFloat
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
width
(
_
child
:
UIView
,
width
:
CGFloat
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
width
(
parent
:
v
,
child
:
child
,
width
:
width
,
multiplier
:
multiplier
)
Layout
.
width
(
parent
:
v
,
child
:
child
,
width
:
width
)
return
self
return
self
}
}
/**
/**
Sets the width of a view assuming a child context view.
Sets the width of a view assuming a child context view.
- Parameter width: A CGFloat value.
- Parameter width: A CGFloat value.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
width
(
_
width
:
CGFloat
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
width
(
_
width
:
CGFloat
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
self
.
width
(
v
,
width
:
width
,
multiplier
:
multiplier
)
return
self
.
width
(
v
,
width
:
width
)
}
}
/**
/**
Sets the height of a view.
Sets the height of a view.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter height: A CGFloat value.
- Parameter height: A CGFloat value.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
height
(
_
child
:
UIView
,
height
:
CGFloat
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
height
(
_
child
:
UIView
,
height
:
CGFloat
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
height
(
parent
:
v
,
child
:
child
,
height
:
height
,
multiplier
:
multiplier
)
Layout
.
height
(
parent
:
v
,
child
:
child
,
height
:
height
)
return
self
return
self
}
}
/**
/**
Sets the height of a view assuming a child context view.
Sets the height of a view assuming a child context view.
- Parameter height: A CGFloat value.
- Parameter height: A CGFloat value.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
height
(
_
height
:
CGFloat
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
height
(
_
height
:
CGFloat
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
self
.
height
(
v
,
height
:
height
,
multiplier
:
multiplier
)
return
self
.
height
(
v
,
height
:
height
)
}
}
/**
/**
Sets the width and height of a view.
Sets the width and height of a view.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter size: A CGSize value.
- Parameter size: A CGSize value.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
size
(
_
child
:
UIView
,
size
:
CGSize
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
size
(
_
child
:
UIView
,
size
:
CGSize
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
size
(
parent
:
v
,
child
:
child
,
size
:
size
,
multiplier
:
multiplier
)
Layout
.
size
(
parent
:
v
,
child
:
child
,
size
:
size
)
return
self
return
self
}
}
/**
/**
Sets the width and height of a view assuming a child context view.
Sets the width and height of a view assuming a child context view.
- Parameter size: A CGSize value.
- Parameter size: A CGSize value.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
size
(
_
size
:
CGSize
=
CGSize
.
zero
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
size
(
_
size
:
CGSize
=
CGSize
.
zero
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
self
.
size
(
v
,
size
:
size
,
multiplier
:
multiplier
)
return
self
.
size
(
v
,
size
:
size
)
}
}
/**
/**
...
@@ -171,14 +165,13 @@ public class Layout {
...
@@ -171,14 +165,13 @@ public class Layout {
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter interimSpace: A CGFloat value for interim interimSpace.
- Parameter interimSpace: A CGFloat value for interim interimSpace.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
horizontally
(
_
children
:
[
UIView
],
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
interimSpace
:
InterimSpace
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
horizontally
(
_
children
:
[
UIView
],
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
interimSpace
:
InterimSpace
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
Layout
.
horizontally
(
parent
:
v
,
children
:
children
,
left
:
left
,
right
:
right
,
interimSpace
:
interimSpace
,
multiplier
:
multiplier
)
Layout
.
horizontally
(
parent
:
v
,
children
:
children
,
left
:
left
,
right
:
right
,
interimSpace
:
interimSpace
)
return
self
return
self
}
}
...
@@ -189,14 +182,13 @@ public class Layout {
...
@@ -189,14 +182,13 @@ public class Layout {
- Parameter top: A CGFloat value for padding the top side.
- Parameter top: A CGFloat value for padding the top side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter interimSpace: A CGFloat value for interim interimSpace.
- Parameter interimSpace: A CGFloat value for interim interimSpace.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
vertically
(
_
children
:
[
UIView
],
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
interimSpace
:
InterimSpace
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
vertically
(
_
children
:
[
UIView
],
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
interimSpace
:
InterimSpace
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
Layout
.
vertically
(
parent
:
v
,
children
:
children
,
top
:
top
,
bottom
:
bottom
,
interimSpace
:
interimSpace
,
multiplier
:
multiplier
)
Layout
.
vertically
(
parent
:
v
,
children
:
children
,
top
:
top
,
bottom
:
bottom
,
interimSpace
:
interimSpace
)
return
self
return
self
}
}
...
@@ -205,15 +197,14 @@ public class Layout {
...
@@ -205,15 +197,14 @@ public class Layout {
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
horizontally
(
_
child
:
UIView
,
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
horizontally
(
_
child
:
UIView
,
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
horizontally
(
parent
:
v
,
child
:
child
,
left
:
left
,
right
:
right
,
multiplier
:
multiplier
)
Layout
.
horizontally
(
parent
:
v
,
child
:
child
,
left
:
left
,
right
:
right
)
return
self
return
self
}
}
...
@@ -221,14 +212,13 @@ public class Layout {
...
@@ -221,14 +212,13 @@ public class Layout {
A child view is horizontally stretched with optional left and right padding.
A child view is horizontally stretched with optional left and right padding.
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
horizontally
(
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
horizontally
(
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
horizontally
(
v
,
left
:
left
,
right
:
right
,
multiplier
:
multiplier
)
return
horizontally
(
v
,
left
:
left
,
right
:
right
)
}
}
/**
/**
...
@@ -236,15 +226,14 @@ public class Layout {
...
@@ -236,15 +226,14 @@ public class Layout {
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter top: A CGFloat value for padding the top side.
- Parameter top: A CGFloat value for padding the top side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
vertically
(
_
child
:
UIView
,
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
vertically
(
_
child
:
UIView
,
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
vertically
(
parent
:
v
,
child
:
child
,
top
:
top
,
bottom
:
bottom
,
multiplier
:
multiplier
)
Layout
.
vertically
(
parent
:
v
,
child
:
child
,
top
:
top
,
bottom
:
bottom
)
return
self
return
self
}
}
...
@@ -252,14 +241,13 @@ public class Layout {
...
@@ -252,14 +241,13 @@ public class Layout {
A child view is vertically stretched with optional left and right padding.
A child view is vertically stretched with optional left and right padding.
- Parameter top: A CGFloat value for padding the top side.
- Parameter top: A CGFloat value for padding the top side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
vertically
(
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
vertically
(
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
vertically
(
v
,
top
:
top
,
bottom
:
bottom
,
multiplier
:
multiplier
)
return
vertically
(
v
,
top
:
top
,
bottom
:
bottom
)
}
}
/**
/**
...
@@ -269,15 +257,14 @@ public class Layout {
...
@@ -269,15 +257,14 @@ public class Layout {
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
edges
(
_
child
:
UIView
,
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
edges
(
_
child
:
UIView
,
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
edges
(
parent
:
v
,
child
:
child
,
top
:
top
,
left
:
left
,
bottom
:
bottom
,
right
:
right
,
multiplier
:
multiplier
)
Layout
.
edges
(
parent
:
v
,
child
:
child
,
top
:
top
,
left
:
left
,
bottom
:
bottom
,
right
:
right
)
return
self
return
self
}
}
...
@@ -288,130 +275,121 @@ public class Layout {
...
@@ -288,130 +275,121 @@ public class Layout {
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
edges
(
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
edges
(
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
edges
(
v
,
top
:
top
,
left
:
left
,
bottom
:
bottom
,
right
:
right
,
multiplier
:
multiplier
)
return
edges
(
v
,
top
:
top
,
left
:
left
,
bottom
:
bottom
,
right
:
right
)
}
}
/**
/**
A child view is aligned from the top with optional top padding.
A child view is aligned from the top with optional top padding.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter top: A CGFloat value for padding the top side.
- Parameter top: A CGFloat value for padding the top side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
top
(
_
child
:
UIView
,
top
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
top
(
_
child
:
UIView
,
top
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
top
(
parent
:
v
,
child
:
child
,
top
:
top
,
multiplier
:
multiplier
)
Layout
.
top
(
parent
:
v
,
child
:
child
,
top
:
top
)
return
self
return
self
}
}
/**
/**
A child view is aligned from the top with optional top padding.
A child view is aligned from the top with optional top padding.
- Parameter top: A CGFloat value for padding the top side.
- Parameter top: A CGFloat value for padding the top side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
top
(
_
top
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
top
(
_
top
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
self
.
top
(
v
,
top
:
top
,
multiplier
:
multiplier
)
return
self
.
top
(
v
,
top
:
top
)
}
}
/**
/**
A child view is aligned from the left with optional left padding.
A child view is aligned from the left with optional left padding.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
left
(
_
child
:
UIView
,
left
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
left
(
_
child
:
UIView
,
left
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
left
(
parent
:
v
,
child
:
child
,
left
:
left
,
multiplier
:
multiplier
)
Layout
.
left
(
parent
:
v
,
child
:
child
,
left
:
left
)
return
self
return
self
}
}
/**
/**
A child view is aligned from the left with optional left padding.
A child view is aligned from the left with optional left padding.
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
left
(
_
left
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
left
(
_
left
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
self
.
left
(
v
,
left
:
left
,
multiplier
:
multiplier
)
return
self
.
left
(
v
,
left
:
left
)
}
}
/**
/**
A child view is aligned from the bottom with optional bottom padding.
A child view is aligned from the bottom with optional bottom padding.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
bottom
(
_
child
:
UIView
,
bottom
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
bottom
(
_
child
:
UIView
,
bottom
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
bottom
(
parent
:
v
,
child
:
child
,
bottom
:
bottom
,
multiplier
:
multiplier
)
Layout
.
bottom
(
parent
:
v
,
child
:
child
,
bottom
:
bottom
)
return
self
return
self
}
}
/**
/**
A child view is aligned from the bottom with optional bottom padding.
A child view is aligned from the bottom with optional bottom padding.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
bottom
(
_
bottom
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
bottom
(
_
bottom
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
self
.
bottom
(
v
,
bottom
:
bottom
,
multiplier
:
multiplier
)
return
self
.
bottom
(
v
,
bottom
:
bottom
)
}
}
/**
/**
A child view is aligned from the right with optional right padding.
A child view is aligned from the right with optional right padding.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
right
(
_
child
:
UIView
,
right
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
right
(
_
child
:
UIView
,
right
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
right
(
parent
:
v
,
child
:
child
,
right
:
right
,
multiplier
:
multiplier
)
Layout
.
right
(
parent
:
v
,
child
:
child
,
right
:
right
)
return
self
return
self
}
}
/**
/**
A child view is aligned from the right with optional right padding.
A child view is aligned from the right with optional right padding.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
right
(
_
right
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
right
(
_
right
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
self
.
right
(
v
,
right
:
right
,
multiplier
:
multiplier
)
return
self
.
right
(
v
,
right
:
right
)
}
}
/**
/**
...
@@ -419,15 +397,14 @@ public class Layout {
...
@@ -419,15 +397,14 @@ public class Layout {
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter top: A CGFloat value for padding the top side.
- Parameter top: A CGFloat value for padding the top side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
topLeft
(
_
child
:
UIView
,
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
topLeft
(
_
child
:
UIView
,
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
topLeft
(
parent
:
v
,
child
:
child
,
top
:
top
,
left
:
left
,
multiplier
:
multiplier
)
Layout
.
topLeft
(
parent
:
v
,
child
:
child
,
top
:
top
,
left
:
left
)
return
self
return
self
}
}
...
@@ -435,14 +412,13 @@ public class Layout {
...
@@ -435,14 +412,13 @@ public class Layout {
A child view is aligned from the top left with optional top and left padding.
A child view is aligned from the top left with optional top and left padding.
- Parameter top: A CGFloat value for padding the top side.
- Parameter top: A CGFloat value for padding the top side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
topLeft
(
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
topLeft
(
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
topLeft
(
v
,
top
:
top
,
left
:
left
,
multiplier
:
multiplier
)
return
topLeft
(
v
,
top
:
top
,
left
:
left
)
}
}
/**
/**
...
@@ -450,15 +426,14 @@ public class Layout {
...
@@ -450,15 +426,14 @@ public class Layout {
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter top: A CGFloat value for padding the top side.
- Parameter top: A CGFloat value for padding the top side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
topRight
(
_
child
:
UIView
,
top
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
topRight
(
_
child
:
UIView
,
top
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
topRight
(
parent
:
v
,
child
:
child
,
top
:
top
,
right
:
right
,
multiplier
:
multiplier
)
Layout
.
topRight
(
parent
:
v
,
child
:
child
,
top
:
top
,
right
:
right
)
return
self
return
self
}
}
...
@@ -466,14 +441,13 @@ public class Layout {
...
@@ -466,14 +441,13 @@ public class Layout {
A child view is aligned from the top right with optional top and right padding.
A child view is aligned from the top right with optional top and right padding.
- Parameter top: A CGFloat value for padding the top side.
- Parameter top: A CGFloat value for padding the top side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
topRight
(
top
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
topRight
(
top
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
topRight
(
v
,
top
:
top
,
right
:
right
,
multiplier
:
multiplier
)
return
topRight
(
v
,
top
:
top
,
right
:
right
)
}
}
/**
/**
...
@@ -481,15 +455,14 @@ public class Layout {
...
@@ -481,15 +455,14 @@ public class Layout {
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
bottomLeft
(
_
child
:
UIView
,
bottom
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
bottomLeft
(
_
child
:
UIView
,
bottom
:
CGFloat
=
0
,
left
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
bottomLeft
(
parent
:
v
,
child
:
child
,
bottom
:
bottom
,
left
:
left
,
multiplier
:
multiplier
)
Layout
.
bottomLeft
(
parent
:
v
,
child
:
child
,
bottom
:
bottom
,
left
:
left
)
return
self
return
self
}
}
...
@@ -497,14 +470,13 @@ public class Layout {
...
@@ -497,14 +470,13 @@ public class Layout {
A child view is aligned from the bottom left with optional bottom and left padding.
A child view is aligned from the bottom left with optional bottom and left padding.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
bottomLeft
(
bottom
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
bottomLeft
(
bottom
:
CGFloat
=
0
,
left
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
bottomLeft
(
v
,
bottom
:
bottom
,
left
:
left
,
multiplier
:
multiplier
)
return
bottomLeft
(
v
,
bottom
:
bottom
,
left
:
left
)
}
}
/**
/**
...
@@ -512,15 +484,14 @@ public class Layout {
...
@@ -512,15 +484,14 @@ public class Layout {
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
bottomRight
(
_
child
:
UIView
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
bottomRight
(
_
child
:
UIView
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
bottomRight
(
parent
:
v
,
child
:
child
,
bottom
:
bottom
,
right
:
right
,
multiplier
:
multiplier
)
Layout
.
bottomRight
(
parent
:
v
,
child
:
child
,
bottom
:
bottom
,
right
:
right
)
return
self
return
self
}
}
...
@@ -528,14 +499,13 @@ public class Layout {
...
@@ -528,14 +499,13 @@ public class Layout {
A child view is aligned from the bottom right with optional bottom and right padding.
A child view is aligned from the bottom right with optional bottom and right padding.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
bottomRight
(
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
bottomRight
(
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
bottomRight
(
v
,
bottom
:
bottom
,
right
:
right
,
multiplier
:
multiplier
)
return
bottomRight
(
v
,
bottom
:
bottom
,
right
:
right
)
}
}
/**
/**
...
@@ -543,15 +513,14 @@ public class Layout {
...
@@ -543,15 +513,14 @@ public class Layout {
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter offsetX: A CGFloat value for the offset along the x axis.
- Parameter offsetX: A CGFloat value for the offset along the x axis.
- Parameter offsetX: A CGFloat value for the offset along the y axis.
- Parameter offsetX: A CGFloat value for the offset along the y axis.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
center
(
_
child
:
UIView
,
offsetX
:
CGFloat
=
0
,
offsetY
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
center
(
_
child
:
UIView
,
offsetX
:
CGFloat
=
0
,
offsetY
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
center
(
parent
:
v
,
child
:
child
,
offsetX
:
offsetX
,
offsetY
:
offsetY
,
multiplier
:
multiplier
)
Layout
.
center
(
parent
:
v
,
child
:
child
,
offsetX
:
offsetX
,
offsetY
:
offsetY
)
return
self
return
self
}
}
...
@@ -559,72 +528,67 @@ public class Layout {
...
@@ -559,72 +528,67 @@ public class Layout {
A child view is aligned at the center with an optional offsetX and offsetY value.
A child view is aligned at the center with an optional offsetX and offsetY value.
- Parameter offsetX: A CGFloat value for the offset along the x axis.
- Parameter offsetX: A CGFloat value for the offset along the x axis.
- Parameter offsetX: A CGFloat value for the offset along the y axis.
- Parameter offsetX: A CGFloat value for the offset along the y axis.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
center
(
offsetX
:
CGFloat
=
0
,
offsetY
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
center
(
offsetX
:
CGFloat
=
0
,
offsetY
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
center
(
v
,
offsetX
:
offsetX
,
offsetY
:
offsetY
,
multiplier
:
multiplier
)
return
center
(
v
,
offsetX
:
offsetX
,
offsetY
:
offsetY
)
}
}
/**
/**
A child view is aligned at the center horizontally with an optional offset value.
A child view is aligned at the center horizontally with an optional offset value.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter offset: A CGFloat value for the offset along the x axis.
- Parameter offset: A CGFloat value for the offset along the x axis.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
centerHorizontally
(
_
child
:
UIView
,
offset
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
centerHorizontally
(
_
child
:
UIView
,
offset
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
centerHorizontally
(
parent
:
v
,
child
:
child
,
offset
:
offset
,
multiplier
:
multiplier
)
Layout
.
centerHorizontally
(
parent
:
v
,
child
:
child
,
offset
:
offset
)
return
self
return
self
}
}
/**
/**
A child view is aligned at the center horizontally with an optional offset value.
A child view is aligned at the center horizontally with an optional offset value.
- Parameter offset: A CGFloat value for the offset along the x axis.
- Parameter offset: A CGFloat value for the offset along the x axis.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
centerHorizontally
(
offset
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
centerHorizontally
(
offset
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
centerHorizontally
(
v
,
offset
:
offset
,
multiplier
:
multiplier
)
return
centerHorizontally
(
v
,
offset
:
offset
)
}
}
/**
/**
A child view is aligned at the center vertically with an optional offset value.
A child view is aligned at the center vertically with an optional offset value.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter offset: A CGFloat value for the offset along the y axis.
- Parameter offset: A CGFloat value for the offset along the y axis.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
centerVertically
(
_
child
:
UIView
,
offset
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
centerVertically
(
_
child
:
UIView
,
offset
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
parent
else
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
return
debugParentNotAvailableMessage
()
}
}
self
.
child
=
child
self
.
child
=
child
Layout
.
centerVertically
(
parent
:
v
,
child
:
child
,
offset
:
offset
,
multiplier
:
multiplier
)
Layout
.
centerVertically
(
parent
:
v
,
child
:
child
,
offset
:
offset
)
return
self
return
self
}
}
/**
/**
A child view is aligned at the center vertically with an optional offset value.
A child view is aligned at the center vertically with an optional offset value.
- Parameter offset: A CGFloat value for the offset along the y axis.
- Parameter offset: A CGFloat value for the offset along the y axis.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
func
centerVertically
(
offset
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
->
Layout
{
public
func
centerVertically
(
offset
:
CGFloat
=
0
)
->
Layout
{
guard
let
v
=
child
else
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
return
debugChildNotAvailableMessage
()
}
}
return
centerVertically
(
v
,
offset
:
offset
,
multiplier
:
multiplier
)
return
centerVertically
(
v
,
offset
:
offset
)
}
}
}
}
...
@@ -634,36 +598,33 @@ extension Layout {
...
@@ -634,36 +598,33 @@ extension Layout {
Sets the width of a view.
Sets the width of a view.
- Parameter parent: A parent UIView context.
- Parameter parent: A parent UIView context.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter multiplier: A CGFloat value.
- Parameter width: A CGFloat value.
- Parameter width: A CGFloat value.
*/
*/
public
class
func
width
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
width
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
=
0
)
{
prepareForConstraint
(
parent
,
child
:
child
)
prepareForConstraint
(
parent
,
child
:
child
)
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
width
,
relatedBy
:
.
equal
,
toItem
:
nil
,
attribute
:
.
width
,
multiplier
:
multiplier
,
constant
:
width
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
width
,
relatedBy
:
.
equal
,
toItem
:
nil
,
attribute
:
.
width
,
multiplier
:
1
,
constant
:
width
))
}
}
/**
/**
Sets the height of a view.
Sets the height of a view.
- Parameter parent: A parent UIView context.
- Parameter parent: A parent UIView context.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter multiplier: A CGFloat value.
- Parameter height: A CGFloat value.
- Parameter height: A CGFloat value.
*/
*/
public
class
func
height
(
parent
:
UIView
,
child
:
UIView
,
height
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
height
(
parent
:
UIView
,
child
:
UIView
,
height
:
CGFloat
=
0
)
{
prepareForConstraint
(
parent
,
child
:
child
)
prepareForConstraint
(
parent
,
child
:
child
)
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
height
,
relatedBy
:
.
equal
,
toItem
:
nil
,
attribute
:
.
height
,
multiplier
:
multiplier
,
constant
:
height
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
height
,
relatedBy
:
.
equal
,
toItem
:
nil
,
attribute
:
.
height
,
multiplier
:
1
,
constant
:
height
))
}
}
/**
/**
Sets the width and height of a view.
Sets the width and height of a view.
- Parameter parent: A parent UIView context.
- Parameter parent: A parent UIView context.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter multiplier: A CGFloat value.
- Parameter size: A CGSize value.
- Parameter size: A CGSize value.
*/
*/
public
class
func
size
(
parent
:
UIView
,
child
:
UIView
,
size
:
CGSize
=
CGSize
.
zero
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
size
(
parent
:
UIView
,
child
:
UIView
,
size
:
CGSize
=
CGSize
.
zero
)
{
Layout
.
width
(
parent
:
parent
,
child
:
child
,
width
:
size
.
width
,
multiplier
:
multiplier
)
Layout
.
width
(
parent
:
parent
,
child
:
child
,
width
:
size
.
width
)
Layout
.
height
(
parent
:
parent
,
child
:
child
,
height
:
size
.
height
,
multiplier
:
multiplier
)
Layout
.
height
(
parent
:
parent
,
child
:
child
,
height
:
size
.
height
)
}
}
/**
/**
...
@@ -674,20 +635,17 @@ extension Layout {
...
@@ -674,20 +635,17 @@ extension Layout {
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter interimSpace: A CGFloat value for interim interimSpace.
- Parameter interimSpace: A CGFloat value for interim interimSpace.
- Parameter multiplier: A CGFloat value.
*/
*/
public
class
func
horizontally
(
parent
:
UIView
,
children
:
[
UIView
],
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
interimSpace
:
InterimSpace
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
horizontally
(
parent
:
UIView
,
children
:
[
UIView
],
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
interimSpace
:
InterimSpace
=
0
)
{
guard
0
<
children
.
count
else
{
return
}
prepareForConstraint
(
parent
,
children
:
children
)
prepareForConstraint
(
parent
,
children
:
children
)
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
0
],
attribute
:
.
left
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
left
,
multiplier
:
multiplier
,
constant
:
left
))
if
0
<
children
.
count
{
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
0
],
attribute
:
.
left
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
left
,
multiplier
:
1
,
constant
:
left
))
for
i
in
1
..<
children
.
count
{
for
i
in
1
..<
children
.
count
{
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
i
],
attribute
:
.
left
,
relatedBy
:
.
equal
,
toItem
:
children
[
i
-
1
],
attribute
:
.
right
,
multiplier
:
multiplier
,
constant
:
interimSpace
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
i
],
attribute
:
.
left
,
relatedBy
:
.
equal
,
toItem
:
children
[
i
-
1
],
attribute
:
.
right
,
multiplier
:
1
,
constant
:
interimSpace
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
i
],
attribute
:
.
width
,
relatedBy
:
.
equal
,
toItem
:
children
[
0
],
attribute
:
.
width
,
multiplier
:
multiplier
,
constant
:
0
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
i
],
attribute
:
.
width
,
relatedBy
:
.
equal
,
toItem
:
children
[
0
],
attribute
:
.
width
,
multiplier
:
1
,
constant
:
0
))
}
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
children
.
count
-
1
],
attribute
:
.
right
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
right
,
multiplier
:
1
,
constant
:
-
right
))
}
}
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
children
.
count
-
1
],
attribute
:
.
right
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
right
,
multiplier
:
multiplier
,
constant
:
-
right
))
}
}
/**
/**
...
@@ -698,20 +656,17 @@ extension Layout {
...
@@ -698,20 +656,17 @@ extension Layout {
- Parameter top: A CGFloat value for padding the top side.
- Parameter top: A CGFloat value for padding the top side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter interimSpace: A CGFloat value for interim interimSpace.
- Parameter interimSpace: A CGFloat value for interim interimSpace.
- Parameter multiplier: A CGFloat value.
*/
*/
public
class
func
vertically
(
parent
:
UIView
,
children
:
[
UIView
],
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
interimSpace
:
InterimSpace
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
vertically
(
parent
:
UIView
,
children
:
[
UIView
],
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
interimSpace
:
InterimSpace
=
0
)
{
guard
0
<
children
.
count
else
{
return
}
prepareForConstraint
(
parent
,
children
:
children
)
prepareForConstraint
(
parent
,
children
:
children
)
if
0
<
children
.
count
{
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
0
],
attribute
:
.
top
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
top
,
multiplier
:
multiplier
,
constant
:
top
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
0
],
attribute
:
.
top
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
top
,
multiplier
:
1
,
constant
:
top
))
for
i
in
1
..<
children
.
count
{
for
i
in
1
..<
children
.
count
{
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
i
],
attribute
:
.
top
,
relatedBy
:
.
equal
,
toItem
:
children
[
i
-
1
],
attribute
:
.
bottom
,
multiplier
:
multiplier
,
constant
:
interimSpace
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
i
],
attribute
:
.
top
,
relatedBy
:
.
equal
,
toItem
:
children
[
i
-
1
],
attribute
:
.
bottom
,
multiplier
:
1
,
constant
:
interimSpace
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
i
],
attribute
:
.
height
,
relatedBy
:
.
equal
,
toItem
:
children
[
0
],
attribute
:
.
height
,
multiplier
:
multiplier
,
constant
:
0
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
i
],
attribute
:
.
height
,
relatedBy
:
.
equal
,
toItem
:
children
[
0
],
attribute
:
.
height
,
multiplier
:
1
,
constant
:
0
))
}
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
children
.
count
-
1
],
attribute
:
.
bottom
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
bottom
,
multiplier
:
1
,
constant
:
-
bottom
))
}
}
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
children
[
children
.
count
-
1
],
attribute
:
.
bottom
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
bottom
,
multiplier
:
multiplier
,
constant
:
-
bottom
))
}
}
/**
/**
...
@@ -720,12 +675,11 @@ extension Layout {
...
@@ -720,12 +675,11 @@ extension Layout {
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
*/
*/
public
class
func
horizontally
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
horizontally
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
{
prepareForConstraint
(
parent
,
child
:
child
)
prepareForConstraint
(
parent
,
child
:
child
)
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
left
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
left
,
multiplier
:
multiplier
,
constant
:
left
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
left
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
left
,
multiplier
:
1
,
constant
:
left
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
right
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
right
,
multiplier
:
multiplier
,
constant
:
-
right
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
right
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
right
,
multiplier
:
1
,
constant
:
-
right
))
}
}
/**
/**
...
@@ -734,12 +688,11 @@ extension Layout {
...
@@ -734,12 +688,11 @@ extension Layout {
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter top: A CGFloat value for padding the top side.
- Parameter top: A CGFloat value for padding the top side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter multiplier: A CGFloat value.
*/
*/
public
class
func
vertically
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
vertically
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
)
{
prepareForConstraint
(
parent
,
child
:
child
)
prepareForConstraint
(
parent
,
child
:
child
)
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
top
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
top
,
multiplier
:
multiplier
,
constant
:
top
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
top
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
top
,
multiplier
:
1
,
constant
:
top
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
bottom
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
bottom
,
multiplier
:
multiplier
,
constant
:
-
bottom
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
bottom
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
bottom
,
multiplier
:
1
,
constant
:
-
bottom
))
}
}
/**
/**
...
@@ -750,11 +703,10 @@ extension Layout {
...
@@ -750,11 +703,10 @@ extension Layout {
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
*/
*/
public
class
func
edges
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
edges
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
{
horizontally
(
parent
:
parent
,
child
:
child
,
left
:
left
,
right
:
right
,
multiplier
:
multiplier
)
horizontally
(
parent
:
parent
,
child
:
child
,
left
:
left
,
right
:
right
)
vertically
(
parent
:
parent
,
child
:
child
,
top
:
top
,
bottom
:
bottom
,
multiplier
:
multiplier
)
vertically
(
parent
:
parent
,
child
:
child
,
top
:
top
,
bottom
:
bottom
)
}
}
/**
/**
...
@@ -762,12 +714,11 @@ extension Layout {
...
@@ -762,12 +714,11 @@ extension Layout {
- Parameter parent: A parent UIView context.
- Parameter parent: A parent UIView context.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter top: A CGFloat value for padding the top side.
- Parameter top: A CGFloat value for padding the top side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
class
func
top
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
top
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
)
{
prepareForConstraint
(
parent
,
child
:
child
)
prepareForConstraint
(
parent
,
child
:
child
)
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
top
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
top
,
multiplier
:
multiplier
,
constant
:
top
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
top
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
top
,
multiplier
:
1
,
constant
:
top
))
}
}
/**
/**
...
@@ -775,12 +726,11 @@ extension Layout {
...
@@ -775,12 +726,11 @@ extension Layout {
- Parameter parent: A parent UIView context.
- Parameter parent: A parent UIView context.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
class
func
left
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
left
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
=
0
)
{
prepareForConstraint
(
parent
,
child
:
child
)
prepareForConstraint
(
parent
,
child
:
child
)
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
left
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
left
,
multiplier
:
multiplier
,
constant
:
left
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
left
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
left
,
multiplier
:
1
,
constant
:
left
))
}
}
/**
/**
...
@@ -788,12 +738,11 @@ extension Layout {
...
@@ -788,12 +738,11 @@ extension Layout {
- Parameter parent: A parent UIView context.
- Parameter parent: A parent UIView context.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
class
func
bottom
(
parent
:
UIView
,
child
:
UIView
,
bottom
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
bottom
(
parent
:
UIView
,
child
:
UIView
,
bottom
:
CGFloat
=
0
)
{
prepareForConstraint
(
parent
,
child
:
child
)
prepareForConstraint
(
parent
,
child
:
child
)
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
bottom
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
bottom
,
multiplier
:
multiplier
,
constant
:
-
bottom
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
bottom
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
bottom
,
multiplier
:
1
,
constant
:
-
bottom
))
}
}
/**
/**
...
@@ -801,12 +750,11 @@ extension Layout {
...
@@ -801,12 +750,11 @@ extension Layout {
- Parameter parent: A parent UIView context.
- Parameter parent: A parent UIView context.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
class
func
right
(
parent
:
UIView
,
child
:
UIView
,
right
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
right
(
parent
:
UIView
,
child
:
UIView
,
right
:
CGFloat
=
0
)
{
prepareForConstraint
(
parent
,
child
:
child
)
prepareForConstraint
(
parent
,
child
:
child
)
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
right
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
right
,
multiplier
:
multiplier
,
constant
:
-
right
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
right
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
right
,
multiplier
:
1
,
constant
:
-
right
))
}
}
/**
/**
...
@@ -815,12 +763,11 @@ extension Layout {
...
@@ -815,12 +763,11 @@ extension Layout {
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter top: A CGFloat value for padding the top side.
- Parameter top: A CGFloat value for padding the top side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
class
func
topLeft
(
parent
:
UIView
,
child
:
UIView
,
top
t
:
CGFloat
=
0
,
left
l
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
topLeft
(
parent
:
UIView
,
child
:
UIView
,
top
t
:
CGFloat
=
0
,
left
l
:
CGFloat
=
0
)
{
top
(
parent
:
parent
,
child
:
child
,
top
:
t
,
multiplier
:
multiplier
)
top
(
parent
:
parent
,
child
:
child
,
top
:
t
)
left
(
parent
:
parent
,
child
:
child
,
left
:
l
,
multiplier
:
multiplier
)
left
(
parent
:
parent
,
child
:
child
,
left
:
l
)
}
}
/**
/**
...
@@ -829,12 +776,11 @@ extension Layout {
...
@@ -829,12 +776,11 @@ extension Layout {
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter top: A CGFloat value for padding the top side.
- Parameter top: A CGFloat value for padding the top side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
class
func
topRight
(
parent
:
UIView
,
child
:
UIView
,
top
t
:
CGFloat
=
0
,
right
r
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
topRight
(
parent
:
UIView
,
child
:
UIView
,
top
t
:
CGFloat
=
0
,
right
r
:
CGFloat
=
0
)
{
top
(
parent
:
parent
,
child
:
child
,
top
:
t
,
multiplier
:
multiplier
)
top
(
parent
:
parent
,
child
:
child
,
top
:
t
)
right
(
parent
:
parent
,
child
:
child
,
right
:
r
,
multiplier
:
multiplie
r
)
right
(
parent
:
parent
,
child
:
child
,
right
:
r
)
}
}
/**
/**
...
@@ -843,12 +789,11 @@ extension Layout {
...
@@ -843,12 +789,11 @@ extension Layout {
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter left: A CGFloat value for padding the left side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
class
func
bottomLeft
(
parent
:
UIView
,
child
:
UIView
,
bottom
b
:
CGFloat
=
0
,
left
l
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
bottomLeft
(
parent
:
UIView
,
child
:
UIView
,
bottom
b
:
CGFloat
=
0
,
left
l
:
CGFloat
=
0
)
{
bottom
(
parent
:
parent
,
child
:
child
,
bottom
:
b
,
multiplier
:
multiplier
)
bottom
(
parent
:
parent
,
child
:
child
,
bottom
:
b
)
left
(
parent
:
parent
,
child
:
child
,
left
:
l
,
multiplier
:
multiplier
)
left
(
parent
:
parent
,
child
:
child
,
left
:
l
)
}
}
/**
/**
...
@@ -857,12 +802,11 @@ extension Layout {
...
@@ -857,12 +802,11 @@ extension Layout {
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter bottom: A CGFloat value for padding the bottom side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter right: A CGFloat value for padding the right side.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
class
func
bottomRight
(
parent
:
UIView
,
child
:
UIView
,
bottom
b
:
CGFloat
=
0
,
right
r
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
bottomRight
(
parent
:
UIView
,
child
:
UIView
,
bottom
b
:
CGFloat
=
0
,
right
r
:
CGFloat
=
0
)
{
bottom
(
parent
:
parent
,
child
:
child
,
bottom
:
b
,
multiplier
:
multiplier
)
bottom
(
parent
:
parent
,
child
:
child
,
bottom
:
b
)
right
(
parent
:
parent
,
child
:
child
,
right
:
r
,
multiplier
:
multiplier
)
right
(
parent
:
parent
,
child
:
child
,
right
:
r
)
}
}
/**
/**
...
@@ -871,12 +815,11 @@ extension Layout {
...
@@ -871,12 +815,11 @@ extension Layout {
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter offsetX: A CGFloat value for the offset along the x axis.
- Parameter offsetX: A CGFloat value for the offset along the x axis.
- Parameter offsetX: A CGFloat value for the offset along the y axis.
- Parameter offsetX: A CGFloat value for the offset along the y axis.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
class
func
center
(
parent
:
UIView
,
child
:
UIView
,
offsetX
:
CGFloat
=
0
,
offsetY
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
center
(
parent
:
UIView
,
child
:
UIView
,
offsetX
:
CGFloat
=
0
,
offsetY
:
CGFloat
=
0
)
{
centerHorizontally
(
parent
:
parent
,
child
:
child
,
offset
:
offsetX
,
multiplier
:
multiplier
)
centerHorizontally
(
parent
:
parent
,
child
:
child
,
offset
:
offsetX
)
centerVertically
(
parent
:
parent
,
child
:
child
,
offset
:
offsetY
,
multiplier
:
multiplier
)
centerVertically
(
parent
:
parent
,
child
:
child
,
offset
:
offsetY
)
}
}
/**
/**
...
@@ -884,12 +827,11 @@ extension Layout {
...
@@ -884,12 +827,11 @@ extension Layout {
- Parameter parent: A parent UIView context.
- Parameter parent: A parent UIView context.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter offset: A CGFloat value for the offset along the y axis.
- Parameter offset: A CGFloat value for the offset along the y axis.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
class
func
centerHorizontally
(
parent
:
UIView
,
child
:
UIView
,
offset
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
centerHorizontally
(
parent
:
UIView
,
child
:
UIView
,
offset
:
CGFloat
=
0
)
{
prepareForConstraint
(
parent
,
child
:
child
)
prepareForConstraint
(
parent
,
child
:
child
)
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
centerX
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
centerX
,
multiplier
:
multiplier
,
constant
:
offset
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
centerX
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
centerX
,
multiplier
:
1
,
constant
:
offset
))
}
}
/**
/**
...
@@ -897,12 +839,11 @@ extension Layout {
...
@@ -897,12 +839,11 @@ extension Layout {
- Parameter parent: A parent UIView context.
- Parameter parent: A parent UIView context.
- Parameter child: A child UIView to layout.
- Parameter child: A child UIView to layout.
- Parameter offset: A CGFloat value for the offset along the y axis.
- Parameter offset: A CGFloat value for the offset along the y axis.
- Parameter multiplier: A CGFloat value.
- Returns: The current Layout instance.
- Returns: The current Layout instance.
*/
*/
public
class
func
centerVertically
(
parent
:
UIView
,
child
:
UIView
,
offset
:
CGFloat
=
0
,
multiplier
:
CGFloat
=
1
)
{
public
class
func
centerVertically
(
parent
:
UIView
,
child
:
UIView
,
offset
:
CGFloat
=
0
)
{
prepareForConstraint
(
parent
,
child
:
child
)
prepareForConstraint
(
parent
,
child
:
child
)
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
centerY
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
centerY
,
multiplier
:
multiplier
,
constant
:
offset
))
parent
.
addConstraint
(
NSLayoutConstraint
(
item
:
child
,
attribute
:
.
centerY
,
relatedBy
:
.
equal
,
toItem
:
parent
,
attribute
:
.
centerY
,
multiplier
:
1
,
constant
:
offset
))
}
}
/**
/**
...
...
Sources/iOS/Switch.swift
View file @
09cdb27c
...
@@ -30,38 +30,38 @@
...
@@ -30,38 +30,38 @@
import
UIKit
import
UIKit
@objc(Switch
Control
Style)
@objc(SwitchStyle)
public
enum
Switch
Control
Style
:
Int
{
public
enum
SwitchStyle
:
Int
{
case
light
case
light
case
dark
case
dark
}
}
@objc(Switch
Control
State)
@objc(SwitchState)
public
enum
Switch
Control
State
:
Int
{
public
enum
SwitchState
:
Int
{
case
on
case
on
case
off
case
off
}
}
@objc(Switch
Control
Size)
@objc(SwitchSize)
public
enum
Switch
Control
Size
:
Int
{
public
enum
SwitchSize
:
Int
{
case
small
case
small
case
medium
case
medium
case
large
case
large
}
}
@objc(Switch
Control
Delegate)
@objc(SwitchDelegate)
public
protocol
Switch
Control
Delegate
{
public
protocol
SwitchDelegate
{
/**
/**
A Switch
Control
delegate method for state changes.
A Switch delegate method for state changes.
- Parameter control: Switch
Control
control.
- Parameter control: Switch control.
*/
*/
func
switchStateChanged
(
control
:
Switch
Control
)
func
switchStateChanged
(
control
:
Switch
)
}
}
@objc(Switch
Control
)
@objc(Switch)
open
class
Switch
Control
:
UIControl
{
open
class
Switch
:
UIControl
{
/// An internal reference to the switchState public property.
/// An internal reference to the switchState public property.
private
var
internalSwitch
ControlState
:
SwitchControl
State
=
.
off
private
var
internalSwitch
State
:
Switch
State
=
.
off
/// Track thickness.
/// Track thickness.
private
var
trackThickness
:
CGFloat
=
0
private
var
trackThickness
:
CGFloat
=
0
...
@@ -79,7 +79,7 @@ open class SwitchControl: UIControl {
...
@@ -79,7 +79,7 @@ open class SwitchControl: UIControl {
private
var
bounceOffset
:
CGFloat
=
3
private
var
bounceOffset
:
CGFloat
=
3
/// An Optional delegation method.
/// An Optional delegation method.
open
weak
var
delegate
:
Switch
Control
Delegate
?
open
weak
var
delegate
:
SwitchDelegate
?
/// Indicates if the animation should bounce.
/// Indicates if the animation should bounce.
@IBInspectable
@IBInspectable
...
@@ -170,7 +170,7 @@ open class SwitchControl: UIControl {
...
@@ -170,7 +170,7 @@ open class SwitchControl: UIControl {
@IBInspectable
@IBInspectable
open
override
var
isEnabled
:
Bool
{
open
override
var
isEnabled
:
Bool
{
didSet
{
didSet
{
styleForState
(
state
:
internalSwitch
Control
State
)
styleForState
(
state
:
internalSwitchState
)
}
}
}
}
...
@@ -178,27 +178,27 @@ open class SwitchControl: UIControl {
...
@@ -178,27 +178,27 @@ open class SwitchControl: UIControl {
@IBInspectable
@IBInspectable
public
var
on
:
Bool
{
public
var
on
:
Bool
{
get
{
get
{
return
.
on
==
internalSwitch
Control
State
return
.
on
==
internalSwitchState
}
}
set
(
value
)
{
set
(
value
)
{
setOn
(
on
:
value
,
animated
:
true
)
setOn
(
on
:
value
,
animated
:
true
)
}
}
}
}
/// Switch
Control
state.
/// Switch state.
public
var
switchState
:
Switch
Control
State
{
public
var
switchState
:
SwitchState
{
get
{
get
{
return
internalSwitch
Control
State
return
internalSwitchState
}
}
set
(
value
)
{
set
(
value
)
{
if
value
!=
internalSwitch
Control
State
{
if
value
!=
internalSwitchState
{
internalSwitch
Control
State
=
value
internalSwitchState
=
value
}
}
}
}
}
}
/// Switch
Control
style.
/// Switch style.
public
var
switchStyle
:
Switch
Control
Style
=
.
dark
{
public
var
switchStyle
:
SwitchStyle
=
.
dark
{
didSet
{
didSet
{
switch
switchStyle
{
switch
switchStyle
{
case
.
light
:
case
.
light
:
...
@@ -223,8 +223,8 @@ open class SwitchControl: UIControl {
...
@@ -223,8 +223,8 @@ open class SwitchControl: UIControl {
}
}
}
}
/// Switch
Control
size.
/// Switch size.
public
var
switchSize
:
Switch
Control
Size
=
.
medium
{
public
var
switchSize
:
SwitchSize
=
.
medium
{
didSet
{
didSet
{
switch
switchSize
{
switch
switchSize
{
case
.
small
:
case
.
small
:
...
@@ -245,13 +245,13 @@ open class SwitchControl: UIControl {
...
@@ -245,13 +245,13 @@ open class SwitchControl: UIControl {
open
override
var
frame
:
CGRect
{
open
override
var
frame
:
CGRect
{
didSet
{
didSet
{
layoutSwitch
Control
()
layoutSwitch
()
}
}
}
}
open
override
var
bounds
:
CGRect
{
open
override
var
bounds
:
CGRect
{
didSet
{
didSet
{
layoutSwitch
Control
()
layoutSwitch
()
}
}
}
}
...
@@ -276,9 +276,9 @@ open class SwitchControl: UIControl {
...
@@ -276,9 +276,9 @@ open class SwitchControl: UIControl {
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
prepareTrack
()
prepareTrack
()
prepareButton
()
prepareButton
()
prepareSwitch
Control
Size
(
size
:
.
medium
)
prepareSwitchSize
(
size
:
.
medium
)
prepareSwitch
Control
Style
(
style
:
.
light
)
prepareSwitchStyle
(
style
:
.
light
)
prepareSwitch
Control
State
(
state
:
.
off
)
prepareSwitchState
(
state
:
.
off
)
}
}
/**
/**
...
@@ -294,39 +294,39 @@ open class SwitchControl: UIControl {
...
@@ -294,39 +294,39 @@ open class SwitchControl: UIControl {
super
.
init
(
frame
:
frame
)
super
.
init
(
frame
:
frame
)
prepareTrack
()
prepareTrack
()
prepareButton
()
prepareButton
()
prepareSwitch
Control
Size
(
size
:
.
medium
)
prepareSwitchSize
(
size
:
.
medium
)
prepareSwitch
Control
Style
(
style
:
.
light
)
prepareSwitchStyle
(
style
:
.
light
)
prepareSwitch
Control
State
(
state
:
.
off
)
prepareSwitchState
(
state
:
.
off
)
}
}
/**
/**
An initializer that sets the state, style, and size of the Switch
Control
instance.
An initializer that sets the state, style, and size of the Switch instance.
- Parameter state: A Switch
Control
State value.
- Parameter state: A SwitchState value.
- Parameter style: A Switch
Control
Style value.
- Parameter style: A SwitchStyle value.
- Parameter size: A Switch
Control
Size value.
- Parameter size: A SwitchSize value.
*/
*/
public
init
(
state
:
Switch
ControlState
=
.
off
,
style
:
SwitchControlStyle
=
.
dark
,
size
:
SwitchControl
Size
=
.
medium
)
{
public
init
(
state
:
Switch
State
=
.
off
,
style
:
SwitchStyle
=
.
dark
,
size
:
Switch
Size
=
.
medium
)
{
trackLayer
=
CAShapeLayer
()
trackLayer
=
CAShapeLayer
()
button
=
FabButton
()
button
=
FabButton
()
super
.
init
(
frame
:
CGRect
.
null
)
super
.
init
(
frame
:
CGRect
.
null
)
prepareTrack
()
prepareTrack
()
prepareButton
()
prepareButton
()
prepareSwitch
Control
Size
(
size
:
size
)
prepareSwitchSize
(
size
:
size
)
prepareSwitch
Control
Style
(
style
:
style
)
prepareSwitchStyle
(
style
:
style
)
prepareSwitch
Control
State
(
state
:
state
)
prepareSwitchState
(
state
:
state
)
}
}
open
override
func
willMove
(
toSuperview
newSuperview
:
UIView
?)
{
open
override
func
willMove
(
toSuperview
newSuperview
:
UIView
?)
{
super
.
willMove
(
toSuperview
:
newSuperview
)
super
.
willMove
(
toSuperview
:
newSuperview
)
styleForState
(
state
:
internalSwitch
Control
State
)
styleForState
(
state
:
internalSwitchState
)
}
}
/**
/**
Toggle the Switch
Control
state, if On will be Off, and if Off will be On.
Toggle the Switch state, if On will be Off, and if Off will be On.
- Parameter completion: An Optional completion block.
- Parameter completion: An Optional completion block.
*/
*/
public
func
toggle
(
completion
:
((
Switch
Control
)
->
Void
)?
=
nil
)
{
public
func
toggle
(
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
setSwitch
ControlState
(
state
:
.
on
==
internalSwitchControl
State
?
.
off
:
.
on
,
animated
:
true
,
completion
:
completion
)
setSwitch
State
(
state
:
.
on
==
internalSwitch
State
?
.
off
:
.
on
,
animated
:
true
,
completion
:
completion
)
}
}
/**
/**
...
@@ -334,22 +334,22 @@ open class SwitchControl: UIControl {
...
@@ -334,22 +334,22 @@ open class SwitchControl: UIControl {
- Parameter on: A bool of whether the switch should be in the on state or not.
- Parameter on: A bool of whether the switch should be in the on state or not.
- Parameter animated: A Boolean indicating to set the animation or not.
- Parameter animated: A Boolean indicating to set the animation or not.
*/
*/
public
func
setOn
(
on
:
Bool
,
animated
:
Bool
,
completion
:
((
Switch
Control
)
->
Void
)?
=
nil
)
{
public
func
setOn
(
on
:
Bool
,
animated
:
Bool
,
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
setSwitch
Control
State
(
state
:
on
?
.
on
:
.
off
,
animated
:
animated
,
completion
:
completion
)
setSwitchState
(
state
:
on
?
.
on
:
.
off
,
animated
:
animated
,
completion
:
completion
)
}
}
/**
/**
Set the switchState property with an option to animate.
Set the switchState property with an option to animate.
- Parameter state: The Switch
Control
State to set.
- Parameter state: The SwitchState to set.
- Parameter animated: A Boolean indicating to set the animation or not.
- Parameter animated: A Boolean indicating to set the animation or not.
- Parameter completion: An Optional completion block.
- Parameter completion: An Optional completion block.
*/
*/
public
func
setSwitch
ControlState
(
state
:
SwitchControlState
,
animated
:
Bool
=
true
,
completion
:
((
SwitchControl
)
->
Void
)?
=
nil
)
{
public
func
setSwitch
State
(
state
:
SwitchState
,
animated
:
Bool
=
true
,
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
if
isEnabled
&&
internalSwitch
Control
State
!=
state
{
if
isEnabled
&&
internalSwitchState
!=
state
{
internalSwitch
Control
State
=
state
internalSwitchState
=
state
if
animated
{
if
animated
{
animateToState
(
state
:
state
)
{
[
weak
self
]
_
in
animateToState
(
state
:
state
)
{
[
weak
self
]
_
in
if
let
s
:
Switch
Control
=
self
{
if
let
s
:
Switch
=
self
{
s
.
sendActions
(
for
:
.
valueChanged
)
s
.
sendActions
(
for
:
.
valueChanged
)
completion
?(
s
)
completion
?(
s
)
s
.
delegate
?
.
switchStateChanged
(
control
:
s
)
s
.
delegate
?
.
switchStateChanged
(
control
:
s
)
...
@@ -374,7 +374,7 @@ open class SwitchControl: UIControl {
...
@@ -374,7 +374,7 @@ open class SwitchControl: UIControl {
internal
func
handleTouchUpOutsideOrCanceled
(
sender
:
FabButton
,
event
:
UIEvent
)
{
internal
func
handleTouchUpOutsideOrCanceled
(
sender
:
FabButton
,
event
:
UIEvent
)
{
if
let
v
:
UITouch
=
event
.
touches
(
for
:
sender
)?
.
first
{
if
let
v
:
UITouch
=
event
.
touches
(
for
:
sender
)?
.
first
{
let
q
:
CGFloat
=
sender
.
x
+
v
.
location
(
in
:
sender
)
.
x
-
v
.
previousLocation
(
in
:
sender
)
.
x
let
q
:
CGFloat
=
sender
.
x
+
v
.
location
(
in
:
sender
)
.
x
-
v
.
previousLocation
(
in
:
sender
)
.
x
setSwitch
Control
State
(
state
:
q
>
(
width
-
button
.
width
)
/
2
?
.
on
:
.
off
,
animated
:
true
)
setSwitchState
(
state
:
q
>
(
width
-
button
.
width
)
/
2
?
.
on
:
.
off
,
animated
:
true
)
}
}
}
}
...
@@ -401,7 +401,7 @@ open class SwitchControl: UIControl {
...
@@ -401,7 +401,7 @@ open class SwitchControl: UIControl {
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
if
true
==
trackLayer
.
frame
.
contains
(
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
))
{
if
true
==
trackLayer
.
frame
.
contains
(
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
))
{
setOn
(
on
:
.
on
!=
internalSwitch
Control
State
,
animated
:
true
)
setOn
(
on
:
.
on
!=
internalSwitchState
,
animated
:
true
)
}
}
}
}
...
@@ -423,35 +423,35 @@ open class SwitchControl: UIControl {
...
@@ -423,35 +423,35 @@ open class SwitchControl: UIControl {
/**
/**
Prepares the switchState property. This is used mainly to allow
Prepares the switchState property. This is used mainly to allow
init to set the state value and have an effect.
init to set the state value and have an effect.
- Parameter state: The Switch
Control
State to set.
- Parameter state: The SwitchState to set.
*/
*/
private
func
prepareSwitch
ControlState
(
state
:
SwitchControl
State
)
{
private
func
prepareSwitch
State
(
state
:
Switch
State
)
{
setSwitch
Control
State
(
state
:
state
,
animated
:
false
)
setSwitchState
(
state
:
state
,
animated
:
false
)
}
}
/**
/**
Prepares the switchStyle property. This is used mainly to allow
Prepares the switchStyle property. This is used mainly to allow
init to set the state value and have an effect.
init to set the state value and have an effect.
- Parameter style: The Switch
Control
Style to set.
- Parameter style: The SwitchStyle to set.
*/
*/
private
func
prepareSwitch
ControlStyle
(
style
:
SwitchControl
Style
)
{
private
func
prepareSwitch
Style
(
style
:
Switch
Style
)
{
switchStyle
=
style
switchStyle
=
style
}
}
/**
/**
Prepares the switchSize property. This is used mainly to allow
Prepares the switchSize property. This is used mainly to allow
init to set the size value and have an effect.
init to set the size value and have an effect.
- Parameter size: The Switch
Control
Size to set.
- Parameter size: The SwitchSize to set.
*/
*/
private
func
prepareSwitch
ControlSize
(
size
:
SwitchControl
Size
)
{
private
func
prepareSwitch
Size
(
size
:
Switch
Size
)
{
switchSize
=
size
switchSize
=
size
}
}
/**
/**
Updates the style based on the state.
Updates the style based on the state.
- Parameter state: The Switch
Control
State to set the style to.
- Parameter state: The SwitchState to set the style to.
*/
*/
private
func
styleForState
(
state
:
Switch
Control
State
)
{
private
func
styleForState
(
state
:
SwitchState
)
{
if
isEnabled
{
if
isEnabled
{
updateColorForState
(
state
:
state
)
updateColorForState
(
state
:
state
)
}
else
{
}
else
{
...
@@ -461,9 +461,9 @@ open class SwitchControl: UIControl {
...
@@ -461,9 +461,9 @@ open class SwitchControl: UIControl {
/**
/**
Updates the coloring for the enabled state.
Updates the coloring for the enabled state.
- Parameter state: Switch
Control
State.
- Parameter state: SwitchState.
*/
*/
private
func
updateColorForState
(
state
:
Switch
Control
State
)
{
private
func
updateColorForState
(
state
:
SwitchState
)
{
if
.
on
==
state
{
if
.
on
==
state
{
button
.
backgroundColor
=
buttonOnColor
button
.
backgroundColor
=
buttonOnColor
trackLayer
.
backgroundColor
=
trackOnColor
.
cgColor
trackLayer
.
backgroundColor
=
trackOnColor
.
cgColor
...
@@ -475,9 +475,9 @@ open class SwitchControl: UIControl {
...
@@ -475,9 +475,9 @@ open class SwitchControl: UIControl {
/**
/**
Updates the coloring for the disabled state.
Updates the coloring for the disabled state.
- Parameter state: Switch
Control
State.
- Parameter state: SwitchState.
*/
*/
private
func
updateColorForDisabledState
(
state
:
Switch
Control
State
)
{
private
func
updateColorForDisabledState
(
state
:
SwitchState
)
{
if
.
on
==
state
{
if
.
on
==
state
{
button
.
backgroundColor
=
buttonOnDisabledColor
button
.
backgroundColor
=
buttonOnDisabledColor
trackLayer
.
backgroundColor
=
trackOnDisabledColor
.
cgColor
trackLayer
.
backgroundColor
=
trackOnDisabledColor
.
cgColor
...
@@ -488,7 +488,7 @@ open class SwitchControl: UIControl {
...
@@ -488,7 +488,7 @@ open class SwitchControl: UIControl {
}
}
/// Laout the button and track views.
/// Laout the button and track views.
private
func
layoutSwitch
Control
()
{
private
func
layoutSwitch
()
{
var
w
:
CGFloat
=
0
var
w
:
CGFloat
=
0
switch
switchSize
{
switch
switchSize
{
case
.
small
:
case
.
small
:
...
@@ -508,34 +508,34 @@ open class SwitchControl: UIControl {
...
@@ -508,34 +508,34 @@ open class SwitchControl: UIControl {
onPosition
=
width
-
px
-
buttonDiameter
onPosition
=
width
-
px
-
buttonDiameter
offPosition
=
px
offPosition
=
px
if
.
on
==
internalSwitch
Control
State
{
if
.
on
==
internalSwitchState
{
button
.
x
=
onPosition
button
.
x
=
onPosition
}
}
}
}
/**
/**
Set the switchState property with an animate.
Set the switchState property with an animate.
- Parameter state: The Switch
Control
State to set.
- Parameter state: The SwitchState to set.
- Parameter completion: An Optional completion block.
- Parameter completion: An Optional completion block.
*/
*/
private
func
animateToState
(
state
:
Switch
ControlState
,
completion
:
((
SwitchControl
)
->
Void
)?
=
nil
)
{
private
func
animateToState
(
state
:
Switch
State
,
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
isUserInteractionEnabled
=
false
isUserInteractionEnabled
=
false
UIView
.
animate
(
withDuration
:
0.15
,
UIView
.
animate
(
withDuration
:
0.15
,
delay
:
0.05
,
delay
:
0.05
,
options
:
[
.
curveEaseIn
,
.
curveEaseOut
],
options
:
[
.
curveEaseIn
,
.
curveEaseOut
],
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
s
:
Switch
Control
=
self
{
if
let
s
:
Switch
=
self
{
s
.
button
.
x
=
.
on
==
state
?
s
.
onPosition
+
s
.
bounceOffset
:
s
.
offPosition
-
s
.
bounceOffset
s
.
button
.
x
=
.
on
==
state
?
s
.
onPosition
+
s
.
bounceOffset
:
s
.
offPosition
-
s
.
bounceOffset
s
.
styleForState
(
state
:
state
)
s
.
styleForState
(
state
:
state
)
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
UIView
.
animate
(
withDuration
:
0.15
,
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
s
:
Switch
Control
=
self
{
if
let
s
:
Switch
=
self
{
s
.
button
.
x
=
.
on
==
state
?
s
.
onPosition
:
s
.
offPosition
s
.
button
.
x
=
.
on
==
state
?
s
.
onPosition
:
s
.
offPosition
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
if
let
s
:
Switch
Control
=
self
{
if
let
s
:
Switch
=
self
{
s
.
isUserInteractionEnabled
=
true
s
.
isUserInteractionEnabled
=
true
completion
?(
s
)
completion
?(
s
)
}
}
...
...
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