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
dd004d08
Commit
dd004d08
authored
Jul 13, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MaterialLayer is now Layer and updated for Switch 2.3
parent
6efe0a94
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
107 deletions
+105
-107
Material.xcodeproj/project.pbxproj
+6
-6
Sources/OSX/Color.swift
+1
-3
Sources/iOS/CaptureView.swift
+7
-7
Sources/iOS/Layer.swift
+91
-91
No files found.
Material.xcodeproj/project.pbxproj
View file @
dd004d08
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
96BCB7C61CB40DC500C806FE
/* Icon.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77D1CB40DC500C806FE
/* Icon.swift */
;
};
96BCB7C61CB40DC500C806FE
/* Icon.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77D1CB40DC500C806FE
/* Icon.swift */
;
};
96BCB7C71CB40DC500C806FE
/* MaterialKeyframeAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77E1CB40DC500C806FE
/* MaterialKeyframeAnimation.swift */
;
};
96BCB7C71CB40DC500C806FE
/* MaterialKeyframeAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77E1CB40DC500C806FE
/* MaterialKeyframeAnimation.swift */
;
};
96BCB7C81CB40DC500C806FE
/* MaterialLabel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77F1CB40DC500C806FE
/* MaterialLabel.swift */
;
};
96BCB7C81CB40DC500C806FE
/* MaterialLabel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77F1CB40DC500C806FE
/* MaterialLabel.swift */
;
};
96BCB7C91CB40DC500C806FE
/*
MaterialLayer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7801CB40DC500C806FE
/* Material
Layer.swift */
;
};
96BCB7C91CB40DC500C806FE
/*
Layer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7801CB40DC500C806FE
/*
Layer.swift */
;
};
96BCB7CA1CB40DC500C806FE
/* Layout.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7811CB40DC500C806FE
/* Layout.swift */
;
};
96BCB7CA1CB40DC500C806FE
/* Layout.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7811CB40DC500C806FE
/* Layout.swift */
;
};
96BCB7CB1CB40DC500C806FE
/* MaterialPulseAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7821CB40DC500C806FE
/* MaterialPulseAnimation.swift */
;
};
96BCB7CB1CB40DC500C806FE
/* MaterialPulseAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7821CB40DC500C806FE
/* MaterialPulseAnimation.swift */
;
};
96BCB7CD1CB40DC500C806FE
/* PulseView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7841CB40DC500C806FE
/* PulseView.swift */
;
};
96BCB7CD1CB40DC500C806FE
/* PulseView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7841CB40DC500C806FE
/* PulseView.swift */
;
};
...
@@ -137,7 +137,7 @@
...
@@ -137,7 +137,7 @@
96BCB8311CB4115200C806FE
/* MaterialFont.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77B1CB40DC500C806FE
/* MaterialFont.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8311CB4115200C806FE
/* MaterialFont.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77B1CB40DC500C806FE
/* MaterialFont.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8321CB4115200C806FE
/* RobotoFont.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7941CB40DC500C806FE
/* RobotoFont.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8321CB4115200C806FE
/* RobotoFont.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7941CB40DC500C806FE
/* RobotoFont.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8331CB4115200C806FE
/* Icon.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77D1CB40DC500C806FE
/* Icon.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8331CB4115200C806FE
/* Icon.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77D1CB40DC500C806FE
/* Icon.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8341CB4115200C806FE
/*
MaterialLayer.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7801CB40DC500C806FE
/* Material
Layer.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8341CB4115200C806FE
/*
Layer.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7801CB40DC500C806FE
/*
Layer.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8351CB4115200C806FE
/* MaterialTextLayer.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB78A1CB40DC500C806FE
/* MaterialTextLayer.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8351CB4115200C806FE
/* MaterialTextLayer.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB78A1CB40DC500C806FE
/* MaterialTextLayer.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8361CB4115200C806FE
/* Grid.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7611CB40DC500C806FE
/* Grid.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8361CB4115200C806FE
/* Grid.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7611CB40DC500C806FE
/* Grid.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8371CB4115200C806FE
/* Layout.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7811CB40DC500C806FE
/* Layout.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8371CB4115200C806FE
/* Layout.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7811CB40DC500C806FE
/* Layout.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
...
@@ -249,7 +249,7 @@
...
@@ -249,7 +249,7 @@
96BCB77D1CB40DC500C806FE
/* Icon.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Icon.swift
;
sourceTree
=
"<group>"
;
};
96BCB77D1CB40DC500C806FE
/* Icon.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Icon.swift
;
sourceTree
=
"<group>"
;
};
96BCB77E1CB40DC500C806FE
/* MaterialKeyframeAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialKeyframeAnimation.swift
;
sourceTree
=
"<group>"
;
};
96BCB77E1CB40DC500C806FE
/* MaterialKeyframeAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialKeyframeAnimation.swift
;
sourceTree
=
"<group>"
;
};
96BCB77F1CB40DC500C806FE
/* MaterialLabel.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialLabel.swift
;
sourceTree
=
"<group>"
;
};
96BCB77F1CB40DC500C806FE
/* MaterialLabel.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialLabel.swift
;
sourceTree
=
"<group>"
;
};
96BCB7801CB40DC500C806FE
/*
MaterialLayer.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Material
Layer.swift
;
sourceTree
=
"<group>"
;
};
96BCB7801CB40DC500C806FE
/*
Layer.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Layer.swift
;
sourceTree
=
"<group>"
;
};
96BCB7811CB40DC500C806FE
/* Layout.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Layout.swift
;
sourceTree
=
"<group>"
;
};
96BCB7811CB40DC500C806FE
/* Layout.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Layout.swift
;
sourceTree
=
"<group>"
;
};
96BCB7821CB40DC500C806FE
/* MaterialPulseAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialPulseAnimation.swift
;
sourceTree
=
"<group>"
;
};
96BCB7821CB40DC500C806FE
/* MaterialPulseAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialPulseAnimation.swift
;
sourceTree
=
"<group>"
;
};
96BCB7841CB40DC500C806FE
/* PulseView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PulseView.swift
;
sourceTree
=
"<group>"
;
};
96BCB7841CB40DC500C806FE
/* PulseView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PulseView.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -610,7 +610,7 @@
...
@@ -610,7 +610,7 @@
96BCB80D1CB410FD00C806FE
/* Layer */
=
{
96BCB80D1CB410FD00C806FE
/* Layer */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
96BCB7801CB40DC500C806FE
/*
Material
Layer.swift */
,
96BCB7801CB40DC500C806FE
/* Layer.swift */
,
96BCB78A1CB40DC500C806FE
/* MaterialTextLayer.swift */
,
96BCB78A1CB40DC500C806FE
/* MaterialTextLayer.swift */
,
);
);
name
=
Layer
;
name
=
Layer
;
...
@@ -694,7 +694,7 @@
...
@@ -694,7 +694,7 @@
96BCB8311CB4115200C806FE
/* MaterialFont.swift in Headers */
,
96BCB8311CB4115200C806FE
/* MaterialFont.swift in Headers */
,
96BCB8321CB4115200C806FE
/* RobotoFont.swift in Headers */
,
96BCB8321CB4115200C806FE
/* RobotoFont.swift in Headers */
,
96BCB8331CB4115200C806FE
/* Icon.swift in Headers */
,
96BCB8331CB4115200C806FE
/* Icon.swift in Headers */
,
96BCB8341CB4115200C806FE
/*
Material
Layer.swift in Headers */
,
96BCB8341CB4115200C806FE
/* Layer.swift in Headers */
,
96BCB8351CB4115200C806FE
/* MaterialTextLayer.swift in Headers */
,
96BCB8351CB4115200C806FE
/* MaterialTextLayer.swift in Headers */
,
96BCB8361CB4115200C806FE
/* Grid.swift in Headers */
,
96BCB8361CB4115200C806FE
/* Grid.swift in Headers */
,
96BCB8371CB4115200C806FE
/* Layout.swift in Headers */
,
96BCB8371CB4115200C806FE
/* Layout.swift in Headers */
,
...
@@ -960,7 +960,7 @@
...
@@ -960,7 +960,7 @@
96BCB7B11CB40DC500C806FE
/* Material+UIImage+Crop.swift in Sources */
,
96BCB7B11CB40DC500C806FE
/* Material+UIImage+Crop.swift in Sources */
,
96BCB7B81CB40DC500C806FE
/* MaterialBorder.swift in Sources */
,
96BCB7B81CB40DC500C806FE
/* MaterialBorder.swift in Sources */
,
96BCB7A61CB40DC500C806FE
/* CardView.swift in Sources */
,
96BCB7A61CB40DC500C806FE
/* CardView.swift in Sources */
,
96BCB7C91CB40DC500C806FE
/*
Material
Layer.swift in Sources */
,
96BCB7C91CB40DC500C806FE
/* Layer.swift in Sources */
,
96BCB7E21CB40DC500C806FE
/* RootController.swift in Sources */
,
96BCB7E21CB40DC500C806FE
/* RootController.swift in Sources */
,
96BCB7DC1CB40DC500C806FE
/* RaisedButton.swift in Sources */
,
96BCB7DC1CB40DC500C806FE
/* RaisedButton.swift in Sources */
,
96BCB7DD1CB40DC500C806FE
/* RobotoFont.swift in Sources */
,
96BCB7DD1CB40DC500C806FE
/* RobotoFont.swift in Sources */
,
...
...
Sources/OSX/Color.swift
View file @
dd004d08
...
@@ -326,7 +326,6 @@ public struct Color {
...
@@ -326,7 +326,6 @@ public struct Color {
public
static
let
accent4
:
NSColor
=
NSColor
(
red
:
255
/
255
,
green
:
109
/
255
,
blue
:
0
/
255
,
alpha
:
1
)
public
static
let
accent4
:
NSColor
=
NSColor
(
red
:
255
/
255
,
green
:
109
/
255
,
blue
:
0
/
255
,
alpha
:
1
)
}
}
// deep orange
// deep orange
public
struct
deepOrange
{
public
struct
deepOrange
{
public
static
let
lighten5
:
NSColor
=
NSColor
(
red
:
251
/
255
,
green
:
233
/
255
,
blue
:
231
/
255
,
alpha
:
1
)
public
static
let
lighten5
:
NSColor
=
NSColor
(
red
:
251
/
255
,
green
:
233
/
255
,
blue
:
231
/
255
,
alpha
:
1
)
...
@@ -344,8 +343,7 @@ public struct Color {
...
@@ -344,8 +343,7 @@ public struct Color {
public
static
let
accent3
:
NSColor
=
NSColor
(
red
:
255
/
255
,
green
:
61
/
255
,
blue
:
0
/
255
,
alpha
:
1
)
public
static
let
accent3
:
NSColor
=
NSColor
(
red
:
255
/
255
,
green
:
61
/
255
,
blue
:
0
/
255
,
alpha
:
1
)
public
static
let
accent4
:
NSColor
=
NSColor
(
red
:
221
/
255
,
green
:
44
/
255
,
blue
:
0
/
255
,
alpha
:
1
)
public
static
let
accent4
:
NSColor
=
NSColor
(
red
:
221
/
255
,
green
:
44
/
255
,
blue
:
0
/
255
,
alpha
:
1
)
}
}
// brown
// brown
public
struct
brown
{
public
struct
brown
{
public
static
let
lighten5
:
NSColor
=
NSColor
(
red
:
239
/
255
,
green
:
235
/
255
,
blue
:
233
/
255
,
alpha
:
1
)
public
static
let
lighten5
:
NSColor
=
NSColor
(
red
:
239
/
255
,
green
:
235
/
255
,
blue
:
233
/
255
,
alpha
:
1
)
...
...
Sources/iOS/CaptureView.swift
View file @
dd004d08
...
@@ -223,13 +223,13 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
...
@@ -223,13 +223,13 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
public
private(set)
var
captureSession
:
CaptureSession
!
public
private(set)
var
captureSession
:
CaptureSession
!
/// A reference to the focus layer used in focus animations.
/// A reference to the focus layer used in focus animations.
public
private(set)
var
focusLayer
:
Material
Layer
?
public
private(set)
var
focusLayer
:
Layer
?
/// A reference to the exposure layer used in exposure animations.
/// A reference to the exposure layer used in exposure animations.
public
private(set)
var
exposureLayer
:
Material
Layer
?
public
private(set)
var
exposureLayer
:
Layer
?
/// A reference to the reset layer used in reset animations.
/// A reference to the reset layer used in reset animations.
public
private(set)
var
resetLayer
:
Material
Layer
?
public
private(set)
var
resetLayer
:
Layer
?
/// A reference to the cameraButton.
/// A reference to the cameraButton.
public
var
cameraButton
:
UIButton
?
{
public
var
cameraButton
:
UIButton
?
{
...
@@ -513,7 +513,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
...
@@ -513,7 +513,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
/// Prepares the focusLayer.
/// Prepares the focusLayer.
private
func
prepareFocusLayer
()
{
private
func
prepareFocusLayer
()
{
if
nil
==
focusLayer
{
if
nil
==
focusLayer
{
focusLayer
=
Material
Layer
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
150
,
height
:
150
))
focusLayer
=
Layer
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
150
,
height
:
150
))
focusLayer
!.
isHidden
=
true
focusLayer
!.
isHidden
=
true
focusLayer
!.
borderWidth
=
2
focusLayer
!.
borderWidth
=
2
focusLayer
!.
borderColor
=
Color
.
white
.
cgColor
focusLayer
!.
borderColor
=
Color
.
white
.
cgColor
...
@@ -524,7 +524,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
...
@@ -524,7 +524,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
/// Prepares the exposureLayer.
/// Prepares the exposureLayer.
private
func
prepareExposureLayer
()
{
private
func
prepareExposureLayer
()
{
if
nil
==
exposureLayer
{
if
nil
==
exposureLayer
{
exposureLayer
=
Material
Layer
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
150
,
height
:
150
))
exposureLayer
=
Layer
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
150
,
height
:
150
))
exposureLayer
!.
isHidden
=
true
exposureLayer
!.
isHidden
=
true
exposureLayer
!.
borderWidth
=
2
exposureLayer
!.
borderWidth
=
2
exposureLayer
!.
borderColor
=
Color
.
yellow
.
darken1
.
cgColor
exposureLayer
!.
borderColor
=
Color
.
yellow
.
darken1
.
cgColor
...
@@ -535,7 +535,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
...
@@ -535,7 +535,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
/// Prepares the resetLayer.
/// Prepares the resetLayer.
private
func
prepareResetLayer
()
{
private
func
prepareResetLayer
()
{
if
nil
==
resetLayer
{
if
nil
==
resetLayer
{
resetLayer
=
Material
Layer
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
150
,
height
:
150
))
resetLayer
=
Layer
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
150
,
height
:
150
))
resetLayer
!.
isHidden
=
true
resetLayer
!.
isHidden
=
true
resetLayer
!.
borderWidth
=
2
resetLayer
!.
borderWidth
=
2
resetLayer
!.
borderColor
=
Color
.
red
.
accent1
.
cgColor
resetLayer
!.
borderColor
=
Color
.
red
.
accent1
.
cgColor
...
@@ -544,7 +544,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
...
@@ -544,7 +544,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
}
}
/// Animates the tap and layer.
/// Animates the tap and layer.
private
func
animateTapLayer
(
layer
v
:
Material
Layer
,
point
:
CGPoint
)
{
private
func
animateTapLayer
(
layer
v
:
Layer
,
point
:
CGPoint
)
{
MaterialAnimation
.
animationDisabled
{
MaterialAnimation
.
animationDisabled
{
v
.
transform
=
CATransform3DIdentity
v
.
transform
=
CATransform3DIdentity
v
.
position
=
point
v
.
position
=
point
...
...
Sources/iOS/
Material
Layer.swift
→
Sources/iOS/Layer.swift
View file @
dd004d08
...
@@ -33,14 +33,14 @@ import UIKit
...
@@ -33,14 +33,14 @@ import UIKit
@objc(MaterialDelegate)
@objc(MaterialDelegate)
public
protocol
MaterialDelegate
{}
public
protocol
MaterialDelegate
{}
@objc(
Material
Layer)
@objc(Layer)
public
class
MaterialLayer
:
CAShapeLayer
{
public
class
Layer
:
CAShapeLayer
{
/**
/**
A CAShapeLayer used to manage elements that would be affected by
A CAShapeLayer used to manage elements that would be affected by
the clipToBounds property of the backing layer. For example, this
the clipToBounds property of the backing layer. For example, this
allows the dropshadow effect on the backing layer, while clipping
allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer.
the image to a desired shape within the visualLayer.
*/
*/
public
private(set)
lazy
var
visualLayer
:
CAShapeLayer
=
CAShapeLayer
()
public
private(set)
lazy
var
visualLayer
:
CAShapeLayer
=
CAShapeLayer
()
/// A property that accesses the layer.frame.origin.x property.
/// A property that accesses the layer.frame.origin.x property.
...
@@ -64,11 +64,11 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -64,11 +64,11 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
A property that accesses the layer.frame.size.width property.
A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a
When setting this property in conjunction with the shape property having a
value that is not .None, the height will be adjusted to maintain the correct
value that is not .None, the height will be adjusted to maintain the correct
shape.
shape.
*/
*/
@IBInspectable
public
var
width
:
CGFloat
{
@IBInspectable
public
var
width
:
CGFloat
{
get
{
get
{
return
frame
.
size
.
width
return
frame
.
size
.
width
...
@@ -82,11 +82,11 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -82,11 +82,11 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
A property that accesses the layer.frame.size.height property.
A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a
When setting this property in conjunction with the shape property having a
value that is not .None, the width will be adjusted to maintain the correct
value that is not .None, the width will be adjusted to maintain the correct
shape.
shape.
*/
*/
@IBInspectable
public
var
height
:
CGFloat
{
@IBInspectable
public
var
height
:
CGFloat
{
get
{
get
{
return
frame
.
size
.
height
return
frame
.
size
.
height
...
@@ -100,22 +100,22 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -100,22 +100,22 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
A property that manages an image for the visualLayer's contents
A property that manages an image for the visualLayer's contents
property. Images should not be set to the backing layer's contents
property. Images should not be set to the backing layer's contents
property to avoid conflicts when using clipsToBounds.
property to avoid conflicts when using clipsToBounds.
*/
*/
@IBInspectable
public
var
image
:
UIImage
?
{
@IBInspectable
public
var
image
:
UIImage
?
{
didSet
{
didSet
{
visualLayer
.
contents
=
image
?
.
CG
Image
visualLayer
.
contents
=
image
?
.
cg
Image
}
}
}
}
/**
/**
Allows a relative subrectangle within the range of 0 to 1 to be
Allows a relative subrectangle within the range of 0 to 1 to be
specified for the visualLayer's contents property. This allows
specified for the visualLayer's contents property. This allows
much greater flexibility than the contentsGravity property in
much greater flexibility than the contentsGravity property in
terms of how the image is cropped and stretched.
terms of how the image is cropped and stretched.
*/
*/
public
override
var
contentsRect
:
CGRect
{
public
override
var
contentsRect
:
CGRect
{
didSet
{
didSet
{
visualLayer
.
contentsRect
=
contentsRect
visualLayer
.
contentsRect
=
contentsRect
...
@@ -123,9 +123,9 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -123,9 +123,9 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
A CGRect that defines a stretchable region inside the visualLayer
A CGRect that defines a stretchable region inside the visualLayer
with a fixed border around the edge.
with a fixed border around the edge.
*/
*/
public
override
var
contentsCenter
:
CGRect
{
public
override
var
contentsCenter
:
CGRect
{
didSet
{
didSet
{
visualLayer
.
contentsCenter
=
contentsCenter
visualLayer
.
contentsCenter
=
contentsCenter
...
@@ -133,10 +133,10 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -133,10 +133,10 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
A floating point value that defines a ratio between the pixel
A floating point value that defines a ratio between the pixel
dimensions of the visualLayer's contents property and the size
dimensions of the visualLayer's contents property and the size
of the layer. By default, this value is set to the MaterialDevice.scale.
of the layer. By default, this value is set to the MaterialDevice.scale.
*/
*/
@IBInspectable
public
override
var
contentsScale
:
CGFloat
{
@IBInspectable
public
override
var
contentsScale
:
CGFloat
{
didSet
{
didSet
{
visualLayer
.
contentsScale
=
contentsScale
visualLayer
.
contentsScale
=
contentsScale
...
@@ -146,7 +146,7 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -146,7 +146,7 @@ public class MaterialLayer : CAShapeLayer {
/// A Preset for the contentsGravity property.
/// A Preset for the contentsGravity property.
public
var
contentsGravityPreset
:
MaterialGravity
{
public
var
contentsGravityPreset
:
MaterialGravity
{
didSet
{
didSet
{
contentsGravity
=
MaterialGravityToValue
(
contentsGravityPreset
)
contentsGravity
=
MaterialGravityToValue
(
gravity
:
contentsGravityPreset
)
}
}
}
}
...
@@ -170,13 +170,13 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -170,13 +170,13 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
in order to maintain consitency across UI objects.
*/
*/
public
var
depth
:
MaterialDepth
=
.
None
{
public
var
depth
:
MaterialDepth
=
.
None
{
didSet
{
didSet
{
let
value
:
MaterialDepthType
=
MaterialDepthToValue
(
depth
)
let
value
:
MaterialDepthType
=
MaterialDepthToValue
(
depth
:
depth
)
shadowOffset
=
value
.
offset
shadowOffset
=
value
.
offset
shadowOpacity
=
value
.
opacity
shadowOpacity
=
value
.
opacity
shadowRadius
=
value
.
radius
shadowRadius
=
value
.
radius
...
@@ -185,23 +185,23 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -185,23 +185,23 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
A property that sets the cornerRadius of the backing layer. If the shape
A property that sets the cornerRadius of the backing layer. If the shape
property has a value of .Circle when the cornerRadius is set, it will
property has a value of .Circle when the cornerRadius is set, it will
become .None, as it no longer maintains its circle shape.
become .None, as it no longer maintains its circle shape.
*/
*/
public
var
cornerRadiusPreset
:
MaterialRadius
=
.
None
{
public
var
cornerRadiusPreset
:
MaterialRadius
=
.
None
{
didSet
{
didSet
{
if
let
v
:
MaterialRadius
=
cornerRadiusPreset
{
if
let
v
:
MaterialRadius
=
cornerRadiusPreset
{
cornerRadius
=
MaterialRadiusToValue
(
v
)
cornerRadius
=
MaterialRadiusToValue
(
radius
:
v
)
}
}
}
}
}
}
/**
/**
A property that sets the cornerRadius of the backing layer. If the shape
A property that sets the cornerRadius of the backing layer. If the shape
property has a value of .Circle when the cornerRadius is set, it will
property has a value of .Circle when the cornerRadius is set, it will
become .None, as it no longer maintains its circle shape.
become .None, as it no longer maintains its circle shape.
*/
*/
@IBInspectable
public
override
var
cornerRadius
:
CGFloat
{
@IBInspectable
public
override
var
cornerRadius
:
CGFloat
{
didSet
{
didSet
{
layoutShadowPath
()
layoutShadowPath
()
...
@@ -212,10 +212,10 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -212,10 +212,10 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
A property that manages the overall shape for the object. If either the
A property that manages the overall shape for the object. If either the
width or height property is set, the other will be automatically adjusted
width or height property is set, the other will be automatically adjusted
to maintain the shape of the object.
to maintain the shape of the object.
*/
*/
public
var
shape
:
MaterialShape
=
.
None
{
public
var
shape
:
MaterialShape
=
.
None
{
didSet
{
didSet
{
if
.
None
!=
shape
{
if
.
None
!=
shape
{
...
@@ -232,14 +232,14 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -232,14 +232,14 @@ public class MaterialLayer : CAShapeLayer {
/// A preset property to set the borderWidth.
/// A preset property to set the borderWidth.
public
var
borderWidthPreset
:
MaterialBorder
=
.
None
{
public
var
borderWidthPreset
:
MaterialBorder
=
.
None
{
didSet
{
didSet
{
borderWidth
=
MaterialBorderToValue
(
borderWidthPreset
)
borderWidth
=
MaterialBorderToValue
(
border
:
border
WidthPreset
)
}
}
}
}
/**
/**
An initializer that initializes the object with a NSCoder object.
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
- Parameter aDecoder: A NSCoder instance.
*/
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
contentsGravityPreset
=
.
ResizeAspectFill
contentsGravityPreset
=
.
ResizeAspectFill
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
...
@@ -247,10 +247,10 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -247,10 +247,10 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
An initializer the same as init(). The layer parameter is ignored
An initializer the same as init(). The layer parameter is ignored
to avoid crashes on certain architectures.
to avoid crashes on certain architectures.
- Parameter layer: AnyObject.
- Parameter layer: AnyObject.
*/
*/
public
override
init
(
layer
:
AnyObject
)
{
public
override
init
(
layer
:
AnyObject
)
{
contentsGravityPreset
=
.
ResizeAspectFill
contentsGravityPreset
=
.
ResizeAspectFill
super
.
init
()
super
.
init
()
...
@@ -265,9 +265,9 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -265,9 +265,9 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
An initializer that initializes the object with a CGRect object.
An initializer that initializes the object with a CGRect object.
- Parameter frame: A CGRect instance.
- Parameter frame: A CGRect instance.
*/
*/
public
convenience
init
(
frame
:
CGRect
)
{
public
convenience
init
(
frame
:
CGRect
)
{
self
.
init
()
self
.
init
()
self
.
frame
=
frame
self
.
frame
=
frame
...
@@ -281,52 +281,52 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -281,52 +281,52 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
A method that accepts CAAnimation objects and executes.
A method that accepts CAAnimation objects and executes.
- Parameter animation: A CAAnimation instance.
- Parameter animation: A CAAnimation instance.
*/
*/
public
func
animate
(
animation
:
CAAnimation
)
{
public
func
animate
(
animation
:
CAAnimation
)
{
animation
.
delegate
=
self
animation
.
delegate
=
self
if
let
a
:
CABasicAnimation
=
animation
as?
CABasicAnimation
{
if
let
a
:
CABasicAnimation
=
animation
as?
CABasicAnimation
{
a
.
fromValue
=
(
nil
==
presentation
Layer
()
?
self
:
presentationLayer
()
as!
CALayer
)
.
valueForKeyPath
(
a
.
keyPath
!
)
a
.
fromValue
=
(
nil
==
presentation
()
?
self
:
presentation
()
!
)
.
value
(
forKeyPath
:
a
.
keyPath
!
)
}
}
if
let
a
:
CAPropertyAnimation
=
animation
as?
CAPropertyAnimation
{
if
let
a
:
CAPropertyAnimation
=
animation
as?
CAPropertyAnimation
{
add
Animation
(
a
,
forKey
:
a
.
keyPath
!
)
add
(
a
,
forKey
:
a
.
keyPath
!
)
}
else
if
let
a
:
CAAnimationGroup
=
animation
as?
CAAnimationGroup
{
}
else
if
let
a
:
CAAnimationGroup
=
animation
as?
CAAnimationGroup
{
add
Animation
(
a
,
forKey
:
nil
)
add
(
a
,
forKey
:
nil
)
}
else
if
let
a
:
CATransition
=
animation
as?
CATransition
{
}
else
if
let
a
:
CATransition
=
animation
as?
CATransition
{
add
Animation
(
a
,
forKey
:
kCATransition
)
add
(
a
,
forKey
:
kCATransition
)
}
}
}
}
/**
/**
A delegation method that is executed when the layer starts
A delegation method that is executed when the layer starts
running an animation.
running an animation.
- Parameter anim
: The currently running CAAnimation instance.
- Parameter animation
: The currently running CAAnimation instance.
*/
*/
public
override
func
animationDidStart
(
anim
:
CAAnimation
)
{
public
override
func
animationDidStart
(
_
animation
:
CAAnimation
)
{
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStart
?(
anim
)
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStart
?(
animation
:
animation
)
}
}
/**
/**
A delegation method that is executed when the layer stops
A delegation method that is executed when the layer stops
running an animation.
running an animation.
- Parameter anim: The CAAnimation instance that stopped running.
- Parameter anim: The CAAnimation instance that stopped running.
- Parameter flag: A boolean that indicates if the animation stopped
- Parameter flag: A boolean that indicates if the animation stopped
because it was completed or interrupted. True if completed, false
because it was completed or interrupted. True if completed, false
if interrupted.
if interrupted.
*/
*/
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
public
override
func
animationDidStop
(
_
animation
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
:
CAPropertyAnimation
=
anim
as?
CAPropertyAnimation
{
if
let
a
:
CAPropertyAnimation
=
anim
ation
as?
CAPropertyAnimation
{
if
let
b
:
CABasicAnimation
=
a
as?
CABasicAnimation
{
if
let
b
:
CABasicAnimation
=
a
as?
CABasicAnimation
{
if
let
v
:
AnyObject
=
b
.
toValue
{
if
let
v
:
AnyObject
=
b
.
toValue
{
if
let
k
:
String
=
b
.
keyPath
{
if
let
k
:
String
=
b
.
keyPath
{
setValue
(
v
,
forKeyPath
:
k
)
setValue
(
v
,
forKeyPath
:
k
)
removeAnimation
ForKey
(
k
)
removeAnimation
(
forKey
:
k
)
}
}
}
}
}
}
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStop
?(
animation
:
animation
,
finished
:
flag
)
}
else
if
let
a
:
CAAnimationGroup
=
anim
as?
CAAnimationGroup
{
}
else
if
let
a
:
CAAnimationGroup
=
anim
ation
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
for
x
in
a
.
animations
!
{
animationDidStop
(
x
,
finished
:
true
)
animationDidStop
(
x
,
finished
:
true
)
}
}
...
@@ -363,9 +363,9 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -363,9 +363,9 @@ public class MaterialLayer : CAShapeLayer {
if
.
None
==
depth
{
if
.
None
==
depth
{
shadowPath
=
nil
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CG
Path
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cg
Path
}
else
{
}
else
{
animate
(
MaterialAnimation
.
shadowPath
(
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CG
Path
,
duration
:
0
))
animate
(
animation
:
MaterialAnimation
.
shadowPath
(
path
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cg
Path
,
duration
:
0
))
}
}
}
}
}
}
...
...
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