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
e9006d9e
Commit
e9006d9e
authored
Oct 30, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed layout to anchor
parent
0c77e6eb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
10 deletions
+19
-10
Sources/iOS/Layout.swift
+16
-7
Sources/iOS/LayoutAnchor.swift
+3
-3
No files found.
Sources/iOS/Layout.swift
View file @
e9006d9e
...
@@ -56,15 +56,20 @@ public extension UIView {
...
@@ -56,15 +56,20 @@ public extension UIView {
return
Layout
(
constraintable
:
self
)
return
Layout
(
constraintable
:
self
)
}
}
/// Anchor instance for the view.
var
anchor
:
LayoutAnchor
{
return
LayoutAnchor
(
constraintable
:
self
)
}
/**
/**
Layout
instance for safeAreaLayoutGuide.
Anchor
instance for safeAreaLayoutGuide.
Below iOS 11, it will be same as view.
layout
.
Below iOS 11, it will be same as view.
anchor
.
*/
*/
var
safe
Layout
:
Layout
{
var
safe
Anchor
:
LayoutAnchor
{
if
#available(iOS 11.0, *)
{
if
#available(iOS 11.0, *)
{
return
Layout
(
constraintable
:
safeAreaLayoutGuide
)
return
Layout
Anchor
(
constraintable
:
safeAreaLayoutGuide
)
}
else
{
}
else
{
return
layout
return
anchor
}
}
}
}
}
}
...
@@ -535,8 +540,12 @@ private extension Layout {
...
@@ -535,8 +540,12 @@ private extension Layout {
*/
*/
func
constraint
(
_
attributes
:
[
LayoutAttribute
],
to
anchor
:
LayoutAnchorable
,
constants
:
[
CGFloat
])
->
Layout
{
func
constraint
(
_
attributes
:
[
LayoutAttribute
],
to
anchor
:
LayoutAnchorable
,
constants
:
[
CGFloat
])
->
Layout
{
let
from
=
LayoutAnchor
(
constraintable
:
constraintable
,
attributes
:
attributes
)
let
from
=
LayoutAnchor
(
constraintable
:
constraintable
,
attributes
:
attributes
)
let
to
=
anchor
as?
LayoutAnchor
??
LayoutAnchor
(
constraintable
:
(
anchor
as?
UIView
)
??
(
anchor
as?
Layout
)?
.
constraintable
,
attributes
:
attributes
)
var
to
=
anchor
as?
LayoutAnchor
let
constraint
=
LayoutConstraint
(
fromAnchor
:
from
,
toAnchor
:
to
,
constants
:
constants
)
if
to
?
.
attributes
.
isEmpty
??
true
{
let
v
=
(
anchor
as?
UIView
)
??
(
anchor
as?
LayoutAnchor
)?
.
constraintable
to
=
LayoutAnchor
(
constraintable
:
v
,
attributes
:
attributes
)
}
let
constraint
=
LayoutConstraint
(
fromAnchor
:
from
,
toAnchor
:
to
!
,
constants
:
constants
)
var
v
=
constraintable
as?
UIView
var
v
=
constraintable
as?
UIView
if
#available(iOS 9.0, *)
,
v
==
nil
{
if
#available(iOS 9.0, *)
,
v
==
nil
{
...
...
Sources/iOS/LayoutAnchor.swift
View file @
e9006d9e
...
@@ -49,13 +49,13 @@ public struct LayoutAnchor {
...
@@ -49,13 +49,13 @@ public struct LayoutAnchor {
- Parameter view: A Constraintable.
- Parameter view: A Constraintable.
- Parameter attributes: An array of LayoutAtrribute.
- Parameter attributes: An array of LayoutAtrribute.
*/
*/
init
(
constraintable
:
Constraintable
?,
attributes
:
[
LayoutAttribute
])
{
init
(
constraintable
:
Constraintable
?,
attributes
:
[
LayoutAttribute
]
=
[]
)
{
self
.
constraintable
=
constraintable
self
.
constraintable
=
constraintable
self
.
attributes
=
attributes
self
.
attributes
=
attributes
}
}
}
}
public
extension
Layout
{
public
extension
Layout
Anchor
{
/// A layout anchor representing top of the view.
/// A layout anchor representing top of the view.
var
top
:
LayoutAnchor
{
var
top
:
LayoutAnchor
{
return
anchor
(
.
top
)
return
anchor
(
.
top
)
...
@@ -136,7 +136,7 @@ public extension Layout {
...
@@ -136,7 +136,7 @@ public extension Layout {
}
}
}
}
private
extension
Layout
{
private
extension
Layout
Anchor
{
/**
/**
Creates LayoutAnchor with the given attribute.
Creates LayoutAnchor with the given attribute.
- Parameter attribute: A LayoutAttribute.
- Parameter attribute: A LayoutAttribute.
...
...
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