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
bf717d93
Commit
bf717d93
authored
Mar 03, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated MaterialAnimation with fixes to issue-194
parent
a0a9c77a
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
193 additions
and
180 deletions
+193
-180
Examples/Programmatic/App/App/AppNavigationBarViewController.swift
+23
-0
Examples/Programmatic/CardView/CardView.xcodeproj/project.pbxproj
+0
-6
Examples/Programmatic/CardView/CardView/ViewController.swift
+1
-42
Examples/Programmatic/MaterialButton/MaterialButton/ViewController.swift
+0
-21
Examples/Programmatic/MaterialPulseView/MaterialPulseView.xcodeproj/project.pbxproj
+6
-0
Examples/Programmatic/MaterialPulseView/MaterialPulseView/ViewController.swift
+5
-0
Examples/Programmatic/MenuView/MenuView/ViewController.swift
+2
-10
Examples/Programmatic/NavigationBarView/NavigationBarView.xcodeproj/project.pbxproj
+0
-6
Sources/MaterialBasicAnimation.swift
+71
-36
Sources/MaterialButton.swift
+13
-10
Sources/MaterialCollectionViewCell.swift
+11
-8
Sources/MaterialKeyframeAnimation.swift
+5
-2
Sources/MaterialLayer.swift
+7
-4
Sources/MaterialTableViewCell.swift
+11
-8
Sources/MaterialTransitionAnimation.swift
+5
-2
Sources/MaterialView.swift
+11
-7
Sources/TextField.swift
+11
-9
Sources/TextView.swift
+11
-9
No files found.
Examples/Programmatic/App/App/AppNavigationBarViewController.swift
View file @
bf717d93
...
...
@@ -60,6 +60,7 @@ class AppNavigationBarViewController: NavigationBarViewController {
override
func
prepareView
()
{
super
.
prepareView
()
view
.
backgroundColor
=
MaterialColor
.
black
navigationBarViewController
?
.
delegate
=
self
}
/// Toggle SideNavigationViewController left UIViewController.
...
...
@@ -108,3 +109,25 @@ class AppNavigationBarViewController: NavigationBarViewController {
}
}
extension
AppNavigationBarViewController
:
NavigationBarViewControllerDelegate
{
/// Delegation method that executes when the floatingViewController will open.
func
navigationBarViewControllerWillOpenFloatingViewController
(
navigationBarViewController
:
NavigationBarViewController
)
{
print
(
"Will Open"
)
}
/// Delegation method that executes when the floatingViewController will close.
func
navigationBarViewControllerWillCloseFloatingViewController
(
navigationBarViewController
:
NavigationBarViewController
)
{
print
(
"Will Close"
)
}
/// Delegation method that executes when the floatingViewController did open.
func
navigationBarViewControllerDidOpenFloatingViewController
(
navigationBarViewController
:
NavigationBarViewController
)
{
print
(
"Did Open"
)
}
/// Delegation method that executes when the floatingViewController did close.
func
navigationBarViewControllerDidCloseFloatingViewController
(
navigationBarViewController
:
NavigationBarViewController
)
{
print
(
"Did Close"
)
}
}
Examples/Programmatic/CardView/CardView.xcodeproj/project.pbxproj
View file @
bf717d93
...
...
@@ -7,8 +7,6 @@
objects
=
{
/* Begin PBXBuildFile section */
965626701C88B7F4004ADEF7
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9656266F1C88B7F4004ADEF7
/* Material.framework */
;
};
965626711C88B7F4004ADEF7
/* Material.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9656266F1C88B7F4004ADEF7
/* Material.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
967513CA1C136BB7009F455A
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967513C91C136BB7009F455A
/* AppDelegate.swift */
;
};
967513CC1C136BB7009F455A
/* ViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967513CB1C136BB7009F455A
/* ViewController.swift */
;
};
967513D11C136BB7009F455A
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967513D01C136BB7009F455A
/* Assets.xcassets */
;
};
...
...
@@ -22,7 +20,6 @@
dstPath
=
""
;
dstSubfolderSpec
=
10
;
files
=
(
965626711C88B7F4004ADEF7
/* Material.framework in Embed Frameworks */
,
);
name
=
"Embed Frameworks"
;
runOnlyForDeploymentPostprocessing
=
0
;
...
...
@@ -30,7 +27,6 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
9656266F1C88B7F4004ADEF7
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
Material.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"
;
sourceTree
=
"<absolute>"
;
};
967513C61C136BB7009F455A
/* CardView.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
CardView.app
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
967513C91C136BB7009F455A
/* AppDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppDelegate.swift
;
sourceTree
=
"<group>"
;
};
967513CB1C136BB7009F455A
/* ViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewController.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -44,7 +40,6 @@
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
965626701C88B7F4004ADEF7
/* Material.framework in Frameworks */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
...
...
@@ -54,7 +49,6 @@
967513BD1C136BB7009F455A
=
{
isa
=
PBXGroup
;
children
=
(
9656266F1C88B7F4004ADEF7
/* Material.framework */
,
967513C81C136BB7009F455A
/* CardView */
,
967513C71C136BB7009F455A
/* Products */
,
);
...
...
Examples/Programmatic/CardView/CardView/ViewController.swift
View file @
bf717d93
...
...
@@ -58,45 +58,6 @@ class ViewController: UIViewController {
:description: General usage example.
*/
private
func
prepareGeneralCardViewExample
()
{
// let cardView: CardView = CardView()
//
// // Title label.
// let titleLabel: UILabel = UILabel()
// titleLabel.text = "Welcome Back!"
// titleLabel.textColor = MaterialColor.blue.darken1
// titleLabel.font = RobotoFont.mediumWithSize(20)
// cardView.titleLabel = titleLabel
//
// // Detail label.
// let detailLabel: UILabel = UILabel()
// detailLabel.text = "It’s been a while, have you read any new books lately?"
// detailLabel.numberOfLines = 0
// cardView.detailView = detailLabel
//
// // Yes button.
// let btn1: FlatButton = FlatButton()
// btn1.pulseColor = MaterialColor.blue.lighten1
// btn1.pulseScale = false
// btn1.setTitle("YES", forState: .Normal)
// btn1.setTitleColor(MaterialColor.blue.darken1, forState: .Normal)
//
// // No button.
// let btn2: FlatButton = FlatButton()
// btn2.pulseColor = MaterialColor.blue.lighten1
// btn2.pulseScale = false
// btn2.setTitle("NO", forState: .Normal)
// btn2.setTitleColor(MaterialColor.blue.darken1, forState: .Normal)
//
// // Add buttons to left side.
// cardView.leftButtons = [btn1, btn2]
//
// // To support orientation changes, use MaterialLayout.
// view.addSubview(cardView)
// cardView.translatesAutoresizingMaskIntoConstraints = false
// MaterialLayout.alignFromTop(view, child: cardView, top: 100)
// MaterialLayout.alignToParentHorizontally(view, child: cardView, left: 20, right: 20)
let
cardView
:
CardView
=
CardView
()
// Title label.
...
...
@@ -125,7 +86,7 @@ class ViewController: UIViewController {
btn2
.
pulseScale
=
false
btn2
.
setTitle
(
"NO"
,
forState
:
.
Normal
)
btn2
.
setTitleColor
(
MaterialColor
.
blue
.
darken1
,
forState
:
.
Normal
)
// Add buttons to left side.
cardView
.
leftButtons
=
[
btn1
,
btn2
]
...
...
@@ -134,8 +95,6 @@ class ViewController: UIViewController {
cardView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignFromTop
(
view
,
child
:
cardView
,
top
:
100
)
MaterialLayout
.
alignToParentHorizontally
(
view
,
child
:
cardView
,
left
:
20
,
right
:
20
)
cardView
.
animate
(
MaterialAnimation
.
translateY
(
200
))
}
/**
...
...
Examples/Programmatic/MaterialButton/MaterialButton/ViewController.swift
View file @
bf717d93
...
...
@@ -43,7 +43,6 @@ class ViewController: UIViewController {
prepareFlatButtonExample
()
prepareRaisedButtonExample
()
prepareFabButtonExample
()
// prepareFabButtonAnimationExample()
}
/// General preparation statements.
...
...
@@ -81,25 +80,5 @@ class ViewController: UIViewController {
// Add button to UIViewController.
view
.
addSubview
(
button
)
}
/// Prepares the FabButton animation example.
private
func
prepareFabButtonAnimationExample
()
{
let
img
:
UIImage
?
=
UIImage
(
named
:
"ic_create_white"
)
let
button
:
FabButton
=
FabButton
(
frame
:
CGRectMake
(
175
,
315
,
64
,
64
))
button
.
setImage
(
img
,
forState
:
.
Normal
)
button
.
setImage
(
img
,
forState
:
.
Highlighted
)
// Add button to UIViewController.
view
.
addSubview
(
button
)
UIView
.
animateWithDuration
(
0.4
,
delay
:
3
,
usingSpringWithDamping
:
0.6
,
initialSpringVelocity
:
0
,
options
:
.
AllowUserInteraction
,
animations
:
{
button
.
frame
.
origin
.
x
=
300
},
completion
:
nil
)
}
}
Examples/Programmatic/MaterialPulseView/MaterialPulseView.xcodeproj/project.pbxproj
View file @
bf717d93
...
...
@@ -7,6 +7,8 @@
objects
=
{
/* Begin PBXBuildFile section */
965626761C88C218004ADEF7
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965626751C88C218004ADEF7
/* Material.framework */
;
};
965626771C88C218004ADEF7
/* Material.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965626751C88C218004ADEF7
/* Material.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
96DB1C5F1C14AA2800825BE6
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96DB1C5E1C14AA2800825BE6
/* AppDelegate.swift */
;
};
96DB1C611C14AA2800825BE6
/* ViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96DB1C601C14AA2800825BE6
/* ViewController.swift */
;
};
96DB1C661C14AA2800825BE6
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96DB1C651C14AA2800825BE6
/* Assets.xcassets */
;
};
...
...
@@ -20,6 +22,7 @@
dstPath
=
""
;
dstSubfolderSpec
=
10
;
files
=
(
965626771C88C218004ADEF7
/* Material.framework in Embed Frameworks */
,
);
name
=
"Embed Frameworks"
;
runOnlyForDeploymentPostprocessing
=
0
;
...
...
@@ -27,6 +30,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
965626751C88C218004ADEF7
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
Material.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"
;
sourceTree
=
"<absolute>"
;
};
96DB1C5B1C14AA2800825BE6
/* MaterialPulseView.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
MaterialPulseView.app
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
96DB1C5E1C14AA2800825BE6
/* AppDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppDelegate.swift
;
sourceTree
=
"<group>"
;
};
96DB1C601C14AA2800825BE6
/* ViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewController.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -40,6 +44,7 @@
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
965626761C88C218004ADEF7
/* Material.framework in Frameworks */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
...
...
@@ -49,6 +54,7 @@
96DB1C521C14AA2800825BE6
=
{
isa
=
PBXGroup
;
children
=
(
965626751C88C218004ADEF7
/* Material.framework */
,
96DB1C5D1C14AA2800825BE6
/* MaterialPulseView */
,
96DB1C5C1C14AA2800825BE6
/* Products */
,
);
...
...
Examples/Programmatic/MaterialPulseView/MaterialPulseView/ViewController.swift
View file @
bf717d93
...
...
@@ -66,6 +66,11 @@ class ViewController: UIViewController {
MaterialAnimation
.
delay
(
2
)
{
pulseView
.
pulse
()
}
pulseView
.
animate
(
MaterialAnimation
.
animationGroup
([
MaterialAnimation
.
rotate
(
4.5
),
MaterialAnimation
.
translateY
(
300
)
],
duration
:
4
))
}
}
Examples/Programmatic/MenuView/MenuView/ViewController.swift
View file @
bf717d93
...
...
@@ -57,23 +57,15 @@ class ViewController: UIViewController {
/// Handle the menuView touch event.
internal
func
handleMenu
()
{
let
image
:
UIImage
?
if
menuView
.
menu
.
opened
{
menuView
.
menu
.
close
()
image
=
UIImage
(
named
:
"ic_add_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
(
menuView
.
menu
.
views
?
.
first
as?
MaterialButton
)?
.
animate
(
MaterialAnimation
.
rotate
(
-
0.125
)
)
}
else
{
menuView
.
menu
.
open
()
{
(
v
:
UIView
)
in
(
v
as?
MaterialButton
)?
.
pulse
()
}
image
=
UIImage
(
named
:
"ic_close_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
(
menuView
.
menu
.
views
?
.
first
as?
MaterialButton
)?
.
animate
(
MaterialAnimation
.
rotate
(
0.125
)
)
}
// Add a nice rotation animation to the base button.
let
first
:
MaterialButton
?
=
menuView
.
menu
.
views
?
.
first
as?
MaterialButton
first
?
.
animate
(
MaterialAnimation
.
rotate
(
1
))
first
?
.
setImage
(
image
,
forState
:
.
Normal
)
first
?
.
setImage
(
image
,
forState
:
.
Highlighted
)
}
/// Handle the menuView touch event.
...
...
Examples/Programmatic/NavigationBarView/NavigationBarView.xcodeproj/project.pbxproj
View file @
bf717d93
...
...
@@ -7,8 +7,6 @@
objects
=
{
/* Begin PBXBuildFile section */
9656266A1C88242F004ADEF7
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965626691C88242F004ADEF7
/* Material.framework */
;
};
9656266B1C88242F004ADEF7
/* Material.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965626691C88242F004ADEF7
/* Material.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
96D88C831C132C1800B91418
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D88C821C132C1800B91418
/* AppDelegate.swift */
;
};
96D88C851C132C1800B91418
/* ViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D88C841C132C1800B91418
/* ViewController.swift */
;
};
96D88C8A1C132C1800B91418
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D88C891C132C1800B91418
/* Assets.xcassets */
;
};
...
...
@@ -22,7 +20,6 @@
dstPath
=
""
;
dstSubfolderSpec
=
10
;
files
=
(
9656266B1C88242F004ADEF7
/* Material.framework in Embed Frameworks */
,
);
name
=
"Embed Frameworks"
;
runOnlyForDeploymentPostprocessing
=
0
;
...
...
@@ -30,7 +27,6 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
965626691C88242F004ADEF7
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
Material.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"
;
sourceTree
=
"<absolute>"
;
};
96D88C7F1C132C1800B91418
/* NavigationBarView.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
NavigationBarView.app
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
96D88C821C132C1800B91418
/* AppDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppDelegate.swift
;
sourceTree
=
"<group>"
;
};
96D88C841C132C1800B91418
/* ViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewController.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -44,7 +40,6 @@
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
9656266A1C88242F004ADEF7
/* Material.framework in Frameworks */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
...
...
@@ -54,7 +49,6 @@
96D88C761C132C1800B91418
=
{
isa
=
PBXGroup
;
children
=
(
965626691C88242F004ADEF7
/* Material.framework */
,
96D88C811C132C1800B91418
/* NavigationBarView */
,
96D88C801C132C1800B91418
/* Products */
,
);
...
...
Sources/MaterialBasicAnimation.swift
View file @
bf717d93
...
...
@@ -34,218 +34,252 @@ public extension MaterialAnimation {
/**
:name: backgroundColor
*/
public
static
func
backgroundColor
(
color
:
UIColor
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
backgroundColor
(
color
:
UIColor
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"backgroundColor"
)
animation
.
toValue
=
color
.
CGColor
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: cornerRadius
*/
public
static
func
cornerRadius
(
radius
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
cornerRadius
(
radius
:
CGFloat
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"cornerRadius"
)
animation
.
toValue
=
radius
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: translation
*/
public
static
func
transform
(
transform
:
CATransform3D
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
transform
(
transform
:
CATransform3D
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"transform"
)
animation
.
toValue
=
NSValue
(
CATransform3D
:
transform
)
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: rotate
*/
public
static
func
rotate
(
rotations
:
Double
=
1
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
rotate
(
rotations
:
Double
=
1
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"transform.rotation"
)
animation
.
byValue
=
(
M_PI
*
2
*
rotations
)
as
NSNumber
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: rotateX
*/
public
static
func
rotateX
(
rotations
:
Double
=
1
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
rotateX
(
rotations
:
Double
=
1
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"transform.rotation.x"
)
animation
.
byValue
=
(
M_PI
_4
*
rotations
)
as
NSNumber
animation
.
byValue
=
(
M_PI
*
2
*
rotations
)
as
NSNumber
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: rotateY
*/
public
static
func
rotateY
(
rotations
:
Double
=
1
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
rotateY
(
rotations
:
Double
=
1
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"transform.rotation.y"
)
animation
.
byValue
=
(
M_PI
_4
*
rotations
)
as
NSNumber
animation
.
byValue
=
(
M_PI
*
2
*
rotations
)
as
NSNumber
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: rotateZ
*/
public
static
func
rotateZ
(
rotations
:
Double
=
1
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
rotateZ
(
rotations
:
Double
=
1
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"transform.rotation.z"
)
animation
.
byValue
=
(
M_PI_4
*
rotations
)
as
NSNumber
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: scale
*/
public
static
func
scale
(
scale
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
scale
(
scale
:
CGFloat
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"transform.scale"
)
animation
.
toValue
=
scale
as
NSNumber
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: scaleX
*/
public
static
func
scaleX
(
scale
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
scaleX
(
scale
:
CGFloat
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"transform.scale.x"
)
animation
.
toValue
=
scale
as
NSNumber
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: scaleY
*/
public
static
func
scaleY
(
scale
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
scaleY
(
scale
:
CGFloat
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"transform.scale.y"
)
animation
.
toValue
=
scale
as
NSNumber
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: scaleZ
*/
public
static
func
scaleZ
(
scale
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
scaleZ
(
scale
:
CGFloat
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"transform.scale.z"
)
animation
.
toValue
=
scale
as
NSNumber
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: translate
*/
public
static
func
translate
(
translation
:
CGSize
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
translate
(
translation
:
CGSize
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"transform.translation"
)
animation
.
toValue
=
NSValue
(
CGSize
:
translation
)
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: translateX
*/
public
static
func
translateX
(
translation
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
translateX
(
translation
:
CGFloat
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"transform.translation.x"
)
animation
.
toValue
=
translation
as
NSNumber
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: translateY
*/
public
static
func
translateY
(
translation
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
translateY
(
translation
:
CGFloat
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"transform.translation.y"
)
animation
.
toValue
=
translation
as
NSNumber
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: translateZ
*/
public
static
func
translateZ
(
translation
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
translateZ
(
translation
:
CGFloat
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"transform.translation.z"
)
animation
.
toValue
=
translation
as
NSNumber
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
/**
:name: position
*/
public
static
func
position
(
point
:
CGPoint
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
public
static
func
position
(
point
:
CGPoint
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"position"
)
animation
.
toValue
=
NSValue
(
CGPoint
:
point
)
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
public
static
func
shadowPath
(
path
:
CGPath
,
duration
:
CFTimeInterval
=
0
)
->
CABasicAnimation
{
public
static
func
shadowPath
(
path
:
CGPath
,
duration
:
CFTimeInterval
?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
(
keyPath
:
"shadowPath"
)
animation
.
toValue
=
path
animation
.
fillMode
=
MaterialAnimationFillModeToValue
(
.
Forwards
)
animation
.
removedOnCompletion
=
false
animation
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
}
\ No newline at end of file
Sources/MaterialButton.swift
View file @
bf717d93
...
...
@@ -381,16 +381,19 @@ public class MaterialButton : UIButton {
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
:
CAPropertyAnimation
=
anim
as?
CAPropertyAnimation
{
if
let
b
:
CABasicAnimation
=
a
as?
CABasicAnimation
{
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKeyPath
:
b
.
keyPath
!
)
if
let
v
:
AnyObject
=
b
.
toValue
{
if
let
k
:
String
=
b
.
keyPath
{
layer
.
setValue
(
v
,
forKeyPath
:
k
)
layer
.
removeAnimationForKey
(
k
)
}
}
}
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
}
else
if
let
a
:
CAAnimationGroup
=
anim
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
animationDidStop
(
x
,
finished
:
true
)
}
}
layoutVisualLayer
()
}
/**
...
...
@@ -466,7 +469,7 @@ public class MaterialButton : UIButton {
internal
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
visualLayer
.
cornerRadius
=
cornerRadius
}
/// Manages the layout for the shape of the view instance.
...
...
@@ -479,10 +482,10 @@ public class MaterialButton : UIButton {
/// Sets the shadow path.
internal
func
layoutShadowPath
()
{
if
shadowPathAutoSizeEnabled
{
if
.
None
==
self
.
depth
{
layer
.
shadowPath
=
nil
}
else
if
nil
==
layer
.
shadowPath
{
layer
.
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
if
.
None
==
depth
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
}
else
{
animate
(
MaterialAnimation
.
shadowPath
(
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
,
duration
:
0
))
}
...
...
@@ -528,8 +531,8 @@ public class MaterialButton : UIButton {
if
nil
!=
self
&&
nil
!=
self
!.
pulseColor
&&
0
<
self
!.
pulseColorOpacity
{
MaterialAnimation
.
animateWithDuration
(
t
,
animations
:
{
pulseLayer
.
hidden
=
true
})
{
pulseLayer
.
removeFromSuperlayer
()
})
{
pulseLayer
.
removeFromSuperlayer
()
}
}
}
...
...
Sources/MaterialCollectionViewCell.swift
View file @
bf717d93
...
...
@@ -434,16 +434,19 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
:
CAPropertyAnimation
=
anim
as?
CAPropertyAnimation
{
if
let
b
:
CABasicAnimation
=
a
as?
CABasicAnimation
{
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKeyPath
:
b
.
keyPath
!
)
if
let
v
:
AnyObject
=
b
.
toValue
{
if
let
k
:
String
=
b
.
keyPath
{
layer
.
setValue
(
v
,
forKeyPath
:
k
)
layer
.
removeAnimationForKey
(
k
)
}
}
}
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
}
else
if
let
a
:
CAAnimationGroup
=
anim
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
animationDidStop
(
x
,
finished
:
true
)
}
}
layoutVisualLayer
()
}
/**
...
...
@@ -520,7 +523,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
internal
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
visualLayer
.
cornerRadius
=
cornerRadius
}
/// Manages the layout for the shape of the view instance.
...
...
@@ -533,10 +536,10 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
/// Sets the shadow path.
internal
func
layoutShadowPath
()
{
if
shadowPathAutoSizeEnabled
{
if
.
None
==
self
.
depth
{
layer
.
shadowPath
=
nil
}
else
if
nil
==
layer
.
shadowPath
{
layer
.
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
if
.
None
==
depth
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
}
else
{
animate
(
MaterialAnimation
.
shadowPath
(
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
,
duration
:
0
))
}
...
...
Sources/MaterialKeyframeAnimation.swift
View file @
bf717d93
...
...
@@ -56,12 +56,14 @@ public extension MaterialAnimation {
/**
:name: path
*/
public
static
func
path
(
bezierPath
:
UIBezierPath
,
mode
:
MaterialAnimationRotationMode
=
.
Auto
,
duration
:
CFTimeInterval
=
0.25
)
->
CAKeyframeAnimation
{
public
static
func
path
(
bezierPath
:
UIBezierPath
,
mode
:
MaterialAnimationRotationMode
=
.
Auto
,
duration
:
CFTimeInterval
?
=
nil
)
->
CAKeyframeAnimation
{
let
animation
:
CAKeyframeAnimation
=
CAKeyframeAnimation
()
animation
.
keyPath
=
"position"
animation
.
path
=
bezierPath
.
CGPath
animation
.
rotationMode
=
MaterialAnimationRotationModeToValue
(
mode
)
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
}
\ No newline at end of file
Sources/MaterialLayer.swift
View file @
bf717d93
...
...
@@ -310,16 +310,19 @@ public class MaterialLayer : CAShapeLayer {
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
:
CAPropertyAnimation
=
anim
as?
CAPropertyAnimation
{
if
let
b
:
CABasicAnimation
=
a
as?
CABasicAnimation
{
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKeyPath
:
b
.
keyPath
!
)
if
let
v
:
AnyObject
=
b
.
toValue
{
if
let
k
:
String
=
b
.
keyPath
{
setValue
(
v
,
forKeyPath
:
k
)
removeAnimationForKey
(
k
)
}
}
}
removeAnimationForKey
(
a
.
keyPath
!
)
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
}
else
if
let
a
:
CAAnimationGroup
=
anim
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
animationDidStop
(
x
,
finished
:
true
)
}
}
layoutVisualLayer
()
}
/// Prepares the visualLayer property.
...
...
@@ -347,7 +350,7 @@ public class MaterialLayer : CAShapeLayer {
/// Sets the shadow path.
internal
func
layoutShadowPath
()
{
if
shadowPathAutoSizeEnabled
{
if
.
None
==
self
.
depth
{
if
.
None
==
depth
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
...
...
Sources/MaterialTableViewCell.swift
View file @
bf717d93
...
...
@@ -336,16 +336,19 @@ public class MaterialTableViewCell: UITableViewCell {
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
:
CAPropertyAnimation
=
anim
as?
CAPropertyAnimation
{
if
let
b
:
CABasicAnimation
=
a
as?
CABasicAnimation
{
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKeyPath
:
b
.
keyPath
!
)
if
let
v
:
AnyObject
=
b
.
toValue
{
if
let
k
:
String
=
b
.
keyPath
{
layer
.
setValue
(
v
,
forKeyPath
:
k
)
layer
.
removeAnimationForKey
(
k
)
}
}
}
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
}
else
if
let
a
:
CAAnimationGroup
=
anim
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
animationDidStop
(
x
,
finished
:
true
)
}
}
layoutVisualLayer
()
}
/**
...
...
@@ -426,16 +429,16 @@ public class MaterialTableViewCell: UITableViewCell {
internal
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
visualLayer
.
cornerRadius
=
cornerRadius
}
/// Sets the shadow path.
internal
func
layoutShadowPath
()
{
if
shadowPathAutoSizeEnabled
{
if
.
None
==
self
.
depth
{
layer
.
shadowPath
=
nil
}
else
if
nil
==
layer
.
shadowPath
{
layer
.
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
if
.
None
==
depth
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
}
else
{
animate
(
MaterialAnimation
.
shadowPath
(
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
,
duration
:
0
))
}
...
...
Sources/MaterialTransitionAnimation.swift
View file @
bf717d93
...
...
@@ -83,13 +83,15 @@ public extension MaterialAnimation {
/**
:name: transition
*/
public
static
func
transition
(
type
:
MaterialAnimationTransition
,
direction
:
MaterialAnimationTransitionSubType
?
=
nil
,
duration
:
CFTimeInterval
=
0.25
)
->
CATransition
{
public
static
func
transition
(
type
:
MaterialAnimationTransition
,
direction
:
MaterialAnimationTransitionSubType
?
=
nil
,
duration
:
CFTimeInterval
?
=
nil
)
->
CATransition
{
let
animation
:
CATransition
=
CATransition
()
animation
.
type
=
MaterialAnimationTransitionToValue
(
type
)
if
let
d
=
direction
{
animation
.
subtype
=
MaterialAnimationTransitionSubTypeToValue
(
d
)
}
animation
.
duration
=
duration
if
let
v
:
CFTimeInterval
=
duration
{
animation
.
duration
=
v
}
return
animation
}
}
\ No newline at end of file
Sources/MaterialView.swift
View file @
bf717d93
...
...
@@ -422,9 +422,13 @@ public class MaterialView : UIView {
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
:
CAPropertyAnimation
=
anim
as?
CAPropertyAnimation
{
if
let
b
:
CABasicAnimation
=
a
as?
CABasicAnimation
{
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKeyPath
:
b
.
keyPath
!
)
if
let
v
:
AnyObject
=
b
.
toValue
{
if
let
k
:
String
=
b
.
keyPath
{
layer
.
setValue
(
v
,
forKeyPath
:
k
)
layer
.
removeAnimationForKey
(
k
)
}
}
}
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
}
else
if
let
a
:
CAAnimationGroup
=
anim
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
...
...
@@ -457,7 +461,7 @@ public class MaterialView : UIView {
internal
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
visualLayer
.
cornerRadius
=
cornerRadius
}
/// Manages the layout for the shape of the view instance.
...
...
@@ -470,10 +474,10 @@ public class MaterialView : UIView {
/// Sets the shadow path.
internal
func
layoutShadowPath
()
{
if
shadowPathAutoSizeEnabled
{
if
.
None
==
self
.
depth
{
layer
.
shadowPath
=
nil
}
else
if
nil
==
layer
.
shadowPath
{
layer
.
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
if
.
None
==
depth
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
}
else
{
animate
(
MaterialAnimation
.
shadowPath
(
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
,
duration
:
0
))
}
...
...
Sources/TextField.swift
View file @
bf717d93
...
...
@@ -35,9 +35,7 @@ public protocol TextFieldDelegate : UITextFieldDelegate {}
public
class
TextField
:
UITextField
{
/**
This property is the same as clipsToBounds. It crops any of the view's
contents from bleeding past the view's frame. If an image is set using
the image property, then this value does not need to be set, since the
visualLayer's maskToBounds is set to true by default.
contents from bleeding past the view's frame.
*/
public
var
masksToBounds
:
Bool
{
get
{
...
...
@@ -489,9 +487,13 @@ public class TextField : UITextField {
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
:
CAPropertyAnimation
=
anim
as?
CAPropertyAnimation
{
if
let
b
:
CABasicAnimation
=
a
as?
CABasicAnimation
{
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKeyPath
:
b
.
keyPath
!
)
if
let
v
:
AnyObject
=
b
.
toValue
{
if
let
k
:
String
=
b
.
keyPath
{
layer
.
setValue
(
v
,
forKeyPath
:
k
)
layer
.
removeAnimationForKey
(
k
)
}
}
}
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
}
else
if
let
a
:
CAAnimationGroup
=
anim
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
...
...
@@ -579,10 +581,10 @@ public class TextField : UITextField {
/// Sets the shadow path.
internal
func
layoutShadowPath
()
{
if
shadowPathAutoSizeEnabled
{
if
.
None
==
self
.
depth
{
layer
.
shadowPath
=
nil
}
else
if
nil
==
layer
.
shadowPath
{
layer
.
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
if
.
None
==
depth
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
}
else
{
animate
(
MaterialAnimation
.
shadowPath
(
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
,
duration
:
0
))
}
...
...
Sources/TextView.swift
View file @
bf717d93
...
...
@@ -37,9 +37,7 @@ public protocol TextViewDelegate : UITextViewDelegate {}
public
class
TextView
:
UITextView
{
/**
This property is the same as clipsToBounds. It crops any of the view's
contents from bleeding past the view's frame. If an image is set using
the image property, then this value does not need to be set, since the
visualLayer's maskToBounds is set to true by default.
contents from bleeding past the view's frame.
*/
public
var
masksToBounds
:
Bool
{
get
{
...
...
@@ -434,9 +432,13 @@ public class TextView: UITextView {
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
:
CAPropertyAnimation
=
anim
as?
CAPropertyAnimation
{
if
let
b
:
CABasicAnimation
=
a
as?
CABasicAnimation
{
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKeyPath
:
b
.
keyPath
!
)
if
let
v
:
AnyObject
=
b
.
toValue
{
if
let
k
:
String
=
b
.
keyPath
{
layer
.
setValue
(
v
,
forKeyPath
:
k
)
layer
.
removeAnimationForKey
(
k
)
}
}
}
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
}
else
if
let
a
:
CAAnimationGroup
=
anim
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
...
...
@@ -496,10 +498,10 @@ public class TextView: UITextView {
/// Sets the shadow path.
internal
func
layoutShadowPath
()
{
if
shadowPathAutoSizeEnabled
{
if
.
None
==
self
.
depth
{
layer
.
shadowPath
=
nil
}
else
if
nil
==
layer
.
shadowPath
{
layer
.
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
if
.
None
==
depth
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
}
else
{
animate
(
MaterialAnimation
.
shadowPath
(
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CGPath
,
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