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
aa5b61e9
Commit
aa5b61e9
authored
Sep 28, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated internal optional values for MaterialView
parent
0b014dfd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
37 deletions
+46
-37
Source/MaterialView.swift
+46
-37
No files found.
Source/MaterialView.swift
View file @
aa5b61e9
...
@@ -38,7 +38,7 @@ public class MaterialView: UIView {
...
@@ -38,7 +38,7 @@ public class MaterialView: UIView {
*/
*/
public
var
contentsRect
:
CGRect
!
{
public
var
contentsRect
:
CGRect
!
{
didSet
{
didSet
{
visualLayer
.
contentsRect
=
contentsRect
visualLayer
.
contentsRect
=
nil
==
contentsRect
?
CGRectMake
(
0
,
0
,
1
,
1
)
:
contentsRect
!
}
}
}
}
...
@@ -47,7 +47,7 @@ public class MaterialView: UIView {
...
@@ -47,7 +47,7 @@ public class MaterialView: UIView {
*/
*/
public
var
contentsCenter
:
CGRect
!
{
public
var
contentsCenter
:
CGRect
!
{
didSet
{
didSet
{
visualLayer
.
contentsCenter
=
contentsCenter
visualLayer
.
contentsCenter
=
nil
==
contentsCenter
?
CGRectMake
(
0
,
0
,
1
,
1
)
:
contentsCenter
!
}
}
}
}
...
@@ -56,7 +56,7 @@ public class MaterialView: UIView {
...
@@ -56,7 +56,7 @@ public class MaterialView: UIView {
*/
*/
public
var
contentsScale
:
CGFloat
!
{
public
var
contentsScale
:
CGFloat
!
{
didSet
{
didSet
{
visualLayer
.
contentsScale
=
contentsScale
visualLayer
.
contentsScale
=
nil
==
contentsScale
?
UIScreen
.
mainScreen
()
.
scale
:
contentsScale
!
}
}
}
}
...
@@ -65,7 +65,7 @@ public class MaterialView: UIView {
...
@@ -65,7 +65,7 @@ public class MaterialView: UIView {
*/
*/
public
var
contentsGravity
:
MaterialGravity
!
{
public
var
contentsGravity
:
MaterialGravity
!
{
didSet
{
didSet
{
visualLayer
.
contentsGravity
=
MaterialGravityToString
(
contentsGravity
)
visualLayer
.
contentsGravity
=
MaterialGravityToString
(
nil
==
contentsGravity
?
.
ResizeAspectFill
:
contentsGravity
!
)
}
}
}
}
...
@@ -86,10 +86,10 @@ public class MaterialView: UIView {
...
@@ -86,10 +86,10 @@ public class MaterialView: UIView {
*/
*/
public
var
x
:
CGFloat
{
public
var
x
:
CGFloat
{
get
{
get
{
return
layer
.
frame
.
origin
.
x
return
frame
.
origin
.
x
}
}
set
(
value
)
{
set
(
value
)
{
layer
.
frame
.
origin
.
x
=
value
frame
.
origin
.
x
=
value
}
}
}
}
...
@@ -98,10 +98,10 @@ public class MaterialView: UIView {
...
@@ -98,10 +98,10 @@ public class MaterialView: UIView {
*/
*/
public
var
y
:
CGFloat
{
public
var
y
:
CGFloat
{
get
{
get
{
return
layer
.
frame
.
origin
.
y
return
frame
.
origin
.
y
}
}
set
(
value
)
{
set
(
value
)
{
layer
.
frame
.
origin
.
y
=
value
frame
.
origin
.
y
=
value
}
}
}
}
...
@@ -110,12 +110,14 @@ public class MaterialView: UIView {
...
@@ -110,12 +110,14 @@ public class MaterialView: UIView {
*/
*/
public
var
width
:
CGFloat
{
public
var
width
:
CGFloat
{
get
{
get
{
return
visualLayer
.
frame
.
size
.
width
return
frame
.
size
.
width
}
}
set
(
value
)
{
set
(
value
)
{
layer
.
frame
.
size
.
width
=
value
frame
.
size
.
width
=
value
visualLayer
.
frame
.
size
.
width
=
value
if
nil
!=
shape
{
prepareShape
()
frame
.
size
.
height
=
value
prepareShape
()
}
}
}
}
}
...
@@ -124,12 +126,14 @@ public class MaterialView: UIView {
...
@@ -124,12 +126,14 @@ public class MaterialView: UIView {
*/
*/
public
var
height
:
CGFloat
{
public
var
height
:
CGFloat
{
get
{
get
{
return
visualLayer
.
frame
.
size
.
height
return
frame
.
size
.
height
}
}
set
(
value
)
{
set
(
value
)
{
layer
.
frame
.
size
.
height
=
value
frame
.
size
.
height
=
value
visualLayer
.
frame
.
size
.
height
=
value
if
nil
!=
shape
{
prepareShape
()
frame
.
size
.
width
=
value
prepareShape
()
}
}
}
}
}
...
@@ -138,7 +142,7 @@ public class MaterialView: UIView {
...
@@ -138,7 +142,7 @@ public class MaterialView: UIView {
*/
*/
public
var
shadowColor
:
UIColor
!
{
public
var
shadowColor
:
UIColor
!
{
didSet
{
didSet
{
layer
.
shadowColor
=
shadowColor
.
CGColor
layer
.
shadowColor
=
nil
==
shadowColor
?
MaterialColor
.
clear
.
CGColor
:
shadowColor
!
.
CGColor
}
}
}
}
...
@@ -147,7 +151,7 @@ public class MaterialView: UIView {
...
@@ -147,7 +151,7 @@ public class MaterialView: UIView {
*/
*/
public
var
shadowOffset
:
CGSize
!
{
public
var
shadowOffset
:
CGSize
!
{
didSet
{
didSet
{
layer
.
shadowOffset
=
shadowOffset
layer
.
shadowOffset
=
nil
==
shadowOffset
?
CGSizeMake
(
0
,
0
)
:
shadowOffset
!
}
}
}
}
...
@@ -156,7 +160,7 @@ public class MaterialView: UIView {
...
@@ -156,7 +160,7 @@ public class MaterialView: UIView {
*/
*/
public
var
shadowOpacity
:
Float
!
{
public
var
shadowOpacity
:
Float
!
{
didSet
{
didSet
{
layer
.
shadowOpacity
=
shadowOpacity
layer
.
shadowOpacity
=
nil
==
shadowOpacity
?
0
:
shadowOpacity
!
}
}
}
}
...
@@ -165,7 +169,7 @@ public class MaterialView: UIView {
...
@@ -165,7 +169,7 @@ public class MaterialView: UIView {
*/
*/
public
var
shadowRadius
:
CGFloat
!
{
public
var
shadowRadius
:
CGFloat
!
{
didSet
{
didSet
{
layer
.
shadowRadius
=
shadowRadius
layer
.
shadowRadius
=
nil
==
shadowRadius
?
0
:
shadowRadius
!
}
}
}
}
...
@@ -174,7 +178,7 @@ public class MaterialView: UIView {
...
@@ -174,7 +178,7 @@ public class MaterialView: UIView {
*/
*/
public
var
masksToBounds
:
Bool
!
{
public
var
masksToBounds
:
Bool
!
{
didSet
{
didSet
{
visualLayer
.
masksToBounds
=
masksToBounds
visualLayer
.
masksToBounds
=
nil
==
masksToBounds
?
false
:
masksToBounds
!
}
}
}
}
...
@@ -183,7 +187,8 @@ public class MaterialView: UIView {
...
@@ -183,7 +187,8 @@ public class MaterialView: UIView {
*/
*/
public
var
cornerRadius
:
MaterialRadius
!
{
public
var
cornerRadius
:
MaterialRadius
!
{
didSet
{
didSet
{
visualLayer
.
cornerRadius
=
MaterialRadiusToValue
(
cornerRadius
!
)
visualLayer
.
cornerRadius
=
MaterialRadiusToValue
(
nil
==
cornerRadius
?
.
None
:
cornerRadius
!
)
shape
=
nil
}
}
}
}
...
@@ -192,7 +197,14 @@ public class MaterialView: UIView {
...
@@ -192,7 +197,14 @@ public class MaterialView: UIView {
*/
*/
public
var
shape
:
MaterialShape
?
{
public
var
shape
:
MaterialShape
?
{
didSet
{
didSet
{
prepareShape
()
if
nil
!=
shape
{
if
width
<
height
{
frame
.
size
.
width
=
height
}
else
{
frame
.
size
.
height
=
width
}
prepareShape
()
}
}
}
}
}
...
@@ -201,7 +213,7 @@ public class MaterialView: UIView {
...
@@ -201,7 +213,7 @@ public class MaterialView: UIView {
*/
*/
public
var
borderWidth
:
MaterialBorder
!
{
public
var
borderWidth
:
MaterialBorder
!
{
didSet
{
didSet
{
visualLayer
.
borderWidth
=
MaterialBorderToValue
(
borderWidth
!
)
visualLayer
.
borderWidth
=
MaterialBorderToValue
(
nil
==
borderWidth
?
.
None
:
borderWidth
!
)
}
}
}
}
...
@@ -210,7 +222,7 @@ public class MaterialView: UIView {
...
@@ -210,7 +222,7 @@ public class MaterialView: UIView {
*/
*/
public
var
borderColor
:
UIColor
!
{
public
var
borderColor
:
UIColor
!
{
didSet
{
didSet
{
visualLayer
.
borderColor
=
borderColor
.
CGColor
visualLayer
.
borderColor
=
nil
==
borderColor
?
MaterialColor
.
clear
.
CGColor
:
borderColor
!
.
CGColor
}
}
}
}
...
@@ -265,6 +277,14 @@ public class MaterialView: UIView {
...
@@ -265,6 +277,14 @@ public class MaterialView: UIView {
return
CAShapeLayer
.
self
return
CAShapeLayer
.
self
}
}
/**
:name: layoutSubviews
*/
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
visualLayer
.
frame
=
bounds
}
//
//
// :name: prepareView
// :name: prepareView
//
//
...
@@ -290,7 +310,6 @@ public class MaterialView: UIView {
...
@@ -290,7 +310,6 @@ public class MaterialView: UIView {
borderColor
=
MaterialTheme
.
view
.
bordercolor
borderColor
=
MaterialTheme
.
view
.
bordercolor
// visualLayer
// visualLayer
visualLayer
.
bounds
=
CGRectMake
(
0
,
0
,
width
,
height
)
layer
.
addSublayer
(
visualLayer
)
layer
.
addSublayer
(
visualLayer
)
}
}
...
@@ -298,17 +317,7 @@ public class MaterialView: UIView {
...
@@ -298,17 +317,7 @@ public class MaterialView: UIView {
// :name: prepareShape
// :name: prepareShape
//
//
internal
func
prepareShape
()
{
internal
func
prepareShape
()
{
if
nil
!=
shape
{
visualLayer
.
cornerRadius
=
.
Square
==
shape
?
0
:
width
/
2
if
width
<
height
{
layer
.
frame
.
size
.
width
=
height
visualLayer
.
frame
.
size
.
width
=
height
}
else
{
layer
.
frame
.
size
.
height
=
width
visualLayer
.
frame
.
size
.
height
=
width
}
layer
.
cornerRadius
=
.
Square
==
shape
?
0
:
layer
.
frame
.
size
.
width
/
2
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
}
}
}
}
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