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
a2cf6137
Commit
a2cf6137
authored
Sep 28, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
experimental: updated button animations
parent
c81f4dfb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
11 deletions
+39
-11
Source/MaterialButton.swift
+27
-10
Source/MaterialPulseView.swift
+12
-1
Source/MaterialTheme.swift
+0
-0
No files found.
Source/MaterialButton.swift
View file @
a2cf6137
...
@@ -25,14 +25,23 @@ public class MaterialButton : UIButton {
...
@@ -25,14 +25,23 @@ public class MaterialButton : UIButton {
public
private(set)
lazy
var
visualLayer
:
CAShapeLayer
=
CAShapeLayer
()
public
private(set)
lazy
var
visualLayer
:
CAShapeLayer
=
CAShapeLayer
()
//
//
// :name:
pulse
Layer
// :name:
touches
Layer
//
//
internal
lazy
var
pulse
Layer
:
CAShapeLayer
=
CAShapeLayer
()
internal
lazy
var
touches
Layer
:
CAShapeLayer
=
CAShapeLayer
()
//
//
// :name: pulse
ColorOpacity
// :name: pulse
Layer
//
//
internal
var
pulseColorOpacity
:
CGFloat
!
internal
lazy
var
pulseLayer
:
CAShapeLayer
=
CAShapeLayer
()
/**
:name: pulseColorOpacity
*/
public
var
pulseColorOpacity
:
CGFloat
!
{
didSet
{
pulseColorOpacity
=
nil
==
pulseColorOpacity
?
0.5
:
pulseColorOpacity
!
}
}
/**
/**
:name: pulseColor
:name: pulseColor
...
@@ -161,7 +170,7 @@ public class MaterialButton : UIButton {
...
@@ -161,7 +170,7 @@ public class MaterialButton : UIButton {
*/
*/
public
var
cornerRadius
:
MaterialRadius
!
{
public
var
cornerRadius
:
MaterialRadius
!
{
didSet
{
didSet
{
visualL
ayer
.
cornerRadius
=
MaterialRadiusToValue
(
nil
==
cornerRadius
?
.
Radius0
:
cornerRadius
!
)
l
ayer
.
cornerRadius
=
MaterialRadiusToValue
(
nil
==
cornerRadius
?
.
Radius0
:
cornerRadius
!
)
shape
=
nil
shape
=
nil
}
}
}
}
...
@@ -187,7 +196,7 @@ public class MaterialButton : UIButton {
...
@@ -187,7 +196,7 @@ public class MaterialButton : UIButton {
*/
*/
public
var
borderWidth
:
MaterialBorder
!
{
public
var
borderWidth
:
MaterialBorder
!
{
didSet
{
didSet
{
visualL
ayer
.
borderWidth
=
MaterialBorderToValue
(
nil
==
borderWidth
?
.
Border0
:
borderWidth
!
)
l
ayer
.
borderWidth
=
MaterialBorderToValue
(
nil
==
borderWidth
?
.
Border0
:
borderWidth
!
)
}
}
}
}
...
@@ -196,7 +205,7 @@ public class MaterialButton : UIButton {
...
@@ -196,7 +205,7 @@ public class MaterialButton : UIButton {
*/
*/
public
var
borderColor
:
UIColor
!
{
public
var
borderColor
:
UIColor
!
{
didSet
{
didSet
{
visualL
ayer
.
borderColor
=
nil
==
borderColor
?
MaterialColor
.
clear
.
CGColor
:
borderColor
!.
CGColor
l
ayer
.
borderColor
=
nil
==
borderColor
?
MaterialColor
.
clear
.
CGColor
:
borderColor
!.
CGColor
}
}
}
}
...
@@ -265,6 +274,10 @@ public class MaterialButton : UIButton {
...
@@ -265,6 +274,10 @@ public class MaterialButton : UIButton {
public
override
func
layoutSubviews
()
{
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
visualLayer
.
frame
=
bounds
visualLayer
.
frame
=
bounds
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
touchesLayer
.
frame
=
bounds
touchesLayer
.
cornerRadius
=
layer
.
cornerRadius
}
}
/**
/**
...
@@ -323,17 +336,21 @@ public class MaterialButton : UIButton {
...
@@ -323,17 +336,21 @@ public class MaterialButton : UIButton {
visualLayer
.
zPosition
=
-
1
visualLayer
.
zPosition
=
-
1
layer
.
addSublayer
(
visualLayer
)
layer
.
addSublayer
(
visualLayer
)
// touchesLayer
touchesLayer
.
zPosition
=
1000
touchesLayer
.
masksToBounds
=
true
layer
.
addSublayer
(
touchesLayer
)
// pulseLayer
// pulseLayer
pulseLayer
.
hidden
=
true
pulseLayer
.
hidden
=
true
pulseLayer
.
zPosition
=
1000
touchesLayer
.
addSublayer
(
pulseLayer
)
visualLayer
.
addSublayer
(
pulseLayer
)
}
}
//
//
// :name: prepareShape
// :name: prepareShape
//
//
internal
func
prepareShape
()
{
internal
func
prepareShape
()
{
visualL
ayer
.
cornerRadius
=
.
Square
==
shape
?
0
:
width
/
2
l
ayer
.
cornerRadius
=
.
Square
==
shape
?
0
:
width
/
2
}
}
//
//
...
...
Source/MaterialPulseView.swift
View file @
a2cf6137
...
@@ -30,11 +30,20 @@ public class MaterialPulseView: MaterialView {
...
@@ -30,11 +30,20 @@ public class MaterialPulseView: MaterialView {
internal
lazy
var
pulseLayer
:
CAShapeLayer
=
CAShapeLayer
()
internal
lazy
var
pulseLayer
:
CAShapeLayer
=
CAShapeLayer
()
/**
/**
:name: pulseColorOpacity
*/
public
var
pulseColorOpacity
:
CGFloat
!
{
didSet
{
pulseColorOpacity
=
nil
==
pulseColorOpacity
?
0.5
:
pulseColorOpacity
!
}
}
/**
:name: pulseColor
:name: pulseColor
*/
*/
public
var
pulseColor
:
UIColor
?
{
public
var
pulseColor
:
UIColor
?
{
didSet
{
didSet
{
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
MaterialTheme
.
pulseView
.
pulseColorOpacity
)
.
CGColor
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
!
)
.
CGColor
}
}
}
}
...
@@ -109,6 +118,7 @@ public class MaterialPulseView: MaterialView {
...
@@ -109,6 +118,7 @@ public class MaterialPulseView: MaterialView {
super
.
prepareView
()
super
.
prepareView
()
userInteractionEnabled
=
MaterialTheme
.
pulseView
.
userInteractionEnabled
userInteractionEnabled
=
MaterialTheme
.
pulseView
.
userInteractionEnabled
backgroundColor
=
MaterialTheme
.
pulseView
.
backgroudColor
backgroundColor
=
MaterialTheme
.
pulseView
.
backgroudColor
pulseColorOpacity
=
MaterialTheme
.
pulseView
.
pulseColorOpacity
pulseColor
=
MaterialTheme
.
pulseView
.
pulseColor
pulseColor
=
MaterialTheme
.
pulseView
.
pulseColor
contentsRect
=
MaterialTheme
.
pulseView
.
contentsRect
contentsRect
=
MaterialTheme
.
pulseView
.
contentsRect
...
@@ -128,6 +138,7 @@ public class MaterialPulseView: MaterialView {
...
@@ -128,6 +138,7 @@ public class MaterialPulseView: MaterialView {
touchesLayer
.
masksToBounds
=
true
touchesLayer
.
masksToBounds
=
true
layer
.
addSublayer
(
touchesLayer
)
layer
.
addSublayer
(
touchesLayer
)
// pulseLayer
pulseLayer
.
hidden
=
true
pulseLayer
.
hidden
=
true
touchesLayer
.
addSublayer
(
pulseLayer
)
touchesLayer
.
addSublayer
(
pulseLayer
)
}
}
...
...
Source/MaterialTheme.swift
View file @
a2cf6137
This diff is collapsed.
Click to expand it.
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