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
b1aeb2d5
Commit
b1aeb2d5
authored
Aug 27, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
progressive cleanup
parent
ae8f95f3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
151 additions
and
267 deletions
+151
-267
MaterialKit.xcodeproj/project.pbxproj
+4
-0
Source/AddFabButton.swift
+63
-0
Source/FabButton.swift
+0
-62
Source/FlatButton.swift
+10
-87
Source/MaterialButton.swift
+71
-22
Source/RaisedButton.swift
+3
-96
No files found.
MaterialKit.xcodeproj/project.pbxproj
View file @
b1aeb2d5
...
...
@@ -31,6 +31,7 @@
963832851B89070E0015F710
/* CapturePreview.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9638325F1B88E5BF0015F710
/* CapturePreview.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
963832881B8908180015F710
/* Layout.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832871B8908180015F710
/* Layout.swift */
;
};
963832891B89097D0015F710
/* Layout.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832871B8908180015F710
/* Layout.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9638329E1B8EC34D0015F710
/* AddFabButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9638329D1B8EC34D0015F710
/* AddFabButton.swift */
;
};
9A94D0F91B895C8C00F586A5
/* Roboto.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9AAC38531B89559900FE6B2D
/* Roboto.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9A94D0FA1B895EA500F586A5
/* LICENSE in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832631B88E5BF0015F710
/* LICENSE */
;
};
9A94D0FB1B895EA500F586A5
/* Roboto-Regular.ttf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9AAC38591B8956E300FE6B2D
/* Roboto-Regular.ttf */
;
};
...
...
@@ -73,6 +74,7 @@
963832671B88E5BF0015F710
/* TextStorage.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TextStorage.swift
;
sourceTree
=
"<group>"
;
};
963832681B88E5BF0015F710
/* TextView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TextView.swift
;
sourceTree
=
"<group>"
;
};
963832871B8908180015F710
/* Layout.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Layout.swift
;
sourceTree
=
"<group>"
;
};
9638329D1B8EC34D0015F710
/* AddFabButton.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AddFabButton.swift
;
sourceTree
=
"<group>"
;
};
9A94D1081B8A3F5100F586A5
/* MaterialPulseView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialPulseView.swift
;
sourceTree
=
"<group>"
;
};
9A94D10A1B8A485C00F586A5
/* ImageCard.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ImageCard.swift
;
sourceTree
=
"<group>"
;
};
9AAC384C1B89528900FE6B2D
/* BasicCard.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BasicCard.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -193,6 +195,7 @@
children
=
(
65B9657D1B8A7C330055B139
/* MaterialButton.swift */
,
963832601B88E5BF0015F710
/* FabButton.swift */
,
9638329D1B8EC34D0015F710
/* AddFabButton.swift */
,
963832611B88E5BF0015F710
/* FlatButton.swift */
,
963832651B88E5BF0015F710
/* RaisedButton.swift */
,
);
...
...
@@ -367,6 +370,7 @@
65B965751B8A60A00055B139
/* MaterialView.swift in Sources */
,
963832711B88E5BF0015F710
/* Text.swift in Sources */
,
9638326A1B88E5BF0015F710
/* CapturePreview.swift in Sources */
,
9638329E1B8EC34D0015F710
/* AddFabButton.swift in Sources */
,
65B965721B8A578D0055B139
/* MaterialViewController.swift in Sources */
,
9AAC38541B89559900FE6B2D
/* Roboto.swift in Sources */
,
65B9657E1B8A7C330055B139
/* MaterialButton.swift in Sources */
,
...
...
Source/AddFabButton.swift
0 → 100644
View file @
b1aeb2d5
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import
UIKit
public
class
AddFabButton
:
FabButton
{
private
lazy
var
verticalLine
:
UIView
=
UIView
()
private
lazy
var
horizontalLine
:
UIView
=
UIView
()
/**
:name: prepareButton
*/
public
override
func
prepareButton
()
{
super
.
prepareButton
()
preparePlus
()
}
//
// :name: preparePlus
//
// I make the + with two views because
// The label is not actually vertically and horizontally aligned
// Quick hack instead of subclassing UILabel and override drawTextInRect
private
func
preparePlus
()
{
prepareVerticalLine
()
prepareHorizontalLine
()
}
//
// :name: prepareVerticalLine
//
private
func
prepareVerticalLine
()
{
verticalLine
=
UIView
(
frame
:
CGRectMake
(
0
,
0
,
lineWidth
,
CGRectGetHeight
(
backgroundColorView
.
frame
)
/
3.0
))
verticalLine
.
backgroundColor
=
.
whiteColor
()
verticalLine
.
center
=
backgroundColorView
.
center
backgroundColorView
.
addSubview
(
verticalLine
)
}
//
// :name: prepareHorizontalLine
//
private
func
prepareHorizontalLine
()
{
horizontalLine
=
UIView
(
frame
:
CGRectMake
(
0
,
0
,
CGRectGetWidth
(
backgroundColorView
.
frame
)
/
3.0
,
lineWidth
))
horizontalLine
.
backgroundColor
=
.
whiteColor
()
horizontalLine
.
center
=
backgroundColorView
.
center
backgroundColorView
.
addSubview
(
horizontalLine
)
}
}
Source/FabButton.swift
View file @
b1aeb2d5
...
...
@@ -40,73 +40,11 @@ public class FabButton : MaterialButton {
initialize
()
}
/**
:name: drawRect
*/
public
override
func
drawRect
(
rect
:
CGRect
)
{
prepareContext
(
rect
)
prepareBackgroundColorView
()
preparePlus
()
}
//
// :name: initialize
//
internal
func
initialize
()
{
color
=
.
redColor
()
pulseColor
=
.
whiteColor
()
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
}
//
// :name: prepareContext
//
private
func
prepareContext
(
rect
:
CGRect
)
{
let
context
=
UIGraphicsGetCurrentContext
()
CGContextSaveGState
(
context
);
CGContextAddEllipseInRect
(
context
,
rect
)
CGContextSetFillColorWithColor
(
context
,
UIColor
.
clearColor
()
.
CGColor
)
CGContextFillPath
(
context
)
CGContextRestoreGState
(
context
);
}
//
// :name: prepareBackgroundColorView
//
// We need this view so we can use the masksToBounds
// so the pulse doesn't animate off the button
func
prepareBackgroundColorView
()
{
backgroundColorView
=
UIView
()
backgroundColorView
!.
frame
=
bounds
backgroundColorView
!.
layer
.
cornerRadius
=
bounds
.
width
/
2.0
backgroundColorView
!.
backgroundColor
=
color
backgroundColorView
!.
layer
.
masksToBounds
=
true
backgroundColorView
!.
userInteractionEnabled
=
false
insertSubview
(
backgroundColorView
!
,
atIndex
:
0
)
}
//
// :name: preparePlus
//
// I make the + with two views because
// The label is not actually vertically and horizontally aligned
// Quick hack instead of subclassing UILabel and override drawTextInRect
private
func
preparePlus
()
{
prepareVerticalLine
()
prepareHorizontalLine
()
}
private
func
prepareVerticalLine
()
{
verticalLine
=
UIView
(
frame
:
CGRectMake
(
0
,
0
,
lineWidth
,
CGRectGetHeight
(
backgroundColorView
!.
frame
)
/
3.0
))
verticalLine
!.
backgroundColor
=
UIColor
.
whiteColor
()
verticalLine
!.
center
=
backgroundColorView
!.
center
backgroundColorView
!.
addSubview
(
verticalLine
!
)
}
private
func
prepareHorizontalLine
()
{
horizontalLine
=
UIView
(
frame
:
CGRectMake
(
0
,
0
,
CGRectGetWidth
(
backgroundColorView
!.
frame
)
/
3.0
,
lineWidth
))
horizontalLine
!.
backgroundColor
=
UIColor
.
whiteColor
()
horizontalLine
!.
center
=
backgroundColorView
!.
center
backgroundColorView
!.
addSubview
(
horizontalLine
!
)
}
}
Source/FlatButton.swift
View file @
b1aeb2d5
...
...
@@ -21,102 +21,25 @@ import UIKit
public
class
FlatButton
:
MaterialButton
{
public
var
textColor
:
UIColor
?
public
override
func
drawRect
(
rect
:
CGRect
)
{
setupContext
(
rect
)
setupBackgroundColorView
()
}
/**
:name: prepareButton
*/
public
override
func
prepareButton
()
{
super
.
prepareButton
()
}
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
initialize
()
applyShadow
()
}
public
required
override
init
(
frame
:
CGRect
)
{
public
required
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
initialize
()
applyShadow
()
}
func
initialize
()
{
backgroundColorView
=
UIView
()
pulseColor
=
UIColor
.
whiteColor
()
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
}
func
setupContext
(
rect
:
CGRect
)
{
let
context
=
UIGraphicsGetCurrentContext
()
CGContextSaveGState
(
context
);
CGContextSetFillColorWithColor
(
context
,
UIColor
.
clearColor
()
.
CGColor
)
CGContextFillPath
(
context
)
CGContextRestoreGState
(
context
);
}
// We need this view so we can use the masksToBounds
// so the pulse doesn't animate off the button
func
setupBackgroundColorView
()
{
backgroundColorView
!.
frame
=
self
.
bounds
backgroundColorView
!.
layer
.
cornerRadius
=
3.0
backgroundColorView
!.
backgroundColor
=
UIColor
.
clearColor
()
backgroundColorView
!.
layer
.
masksToBounds
=
true
backgroundColorView
!.
userInteractionEnabled
=
false
self
.
insertSubview
(
backgroundColorView
!
,
atIndex
:
0
)
}
func
applyShadow
()
{
layer
.
shadowOffset
=
CGSizeMake
(
1
,
1
)
layer
.
shadowColor
=
UIColor
.
blackColor
()
.
CGColor
layer
.
shadowOpacity
=
0.5
layer
.
shadowRadius
=
5
}
public
override
func
touchesBegan
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
super
.
touchesBegan
(
touches
,
withEvent
:
event
)
pulseTouches
(
touches
)
}
public
override
func
touchesEnded
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
super
.
touchesEnded
(
touches
,
withEvent
:
event
)
shrink
()
removePulse
()
}
public
override
func
touchesCancelled
(
touches
:
Set
<
NSObject
>!
,
withEvent
event
:
UIEvent
!
)
{
super
.
touchesCancelled
(
touches
,
withEvent
:
event
)
shrink
()
removePulse
()
}
func
pulseTouches
(
touches
:
NSSet
)
{
let
touch
=
touches
.
allObjects
.
last
as!
UITouch
let
touchLocation
=
touch
.
locationInView
(
self
)
pulseView
=
UIView
()
pulseView
!.
frame
=
CGRectMake
(
0
,
0
,
self
.
bounds
.
size
.
height
,
self
.
bounds
.
size
.
height
)
pulseView
!.
layer
.
cornerRadius
=
bounds
.
height
/
2.0
pulseView
!.
center
=
touchLocation
pulseView
!.
backgroundColor
=
pulseColor
!.
colorWithAlphaComponent
(
0.5
)
backgroundColorView
!.
addSubview
(
pulseView
!
)
textColor
=
self
.
titleLabel
?
.
textColor
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
self
.
pulseView
!.
transform
=
CGAffineTransformMakeScale
(
10
,
10
)
self
.
transform
=
CGAffineTransformMakeScale
(
1.05
,
1.1
)
self
.
setTitleColor
(
UIColor
.
whiteColor
(),
forState
:
.
Normal
)
},
completion
:
nil
)
}
func
shrink
()
{
UIView
.
animateWithDuration
(
0.3
,
delay
:
0.0
,
usingSpringWithDamping
:
0.2
,
initialSpringVelocity
:
10
,
options
:
nil
,
animations
:
{
self
.
transform
=
CGAffineTransformIdentity
},
completion
:
nil
)
}
func
removePulse
()
{
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
()
->
Void
in
self
.
pulseView
!.
alpha
=
0.0
self
.
setTitleColor
(
self
.
textColor
,
forState
:
.
Normal
)
})
{
(
finished
)
->
Void
in
self
.
pulseView
!.
removeFromSuperview
()
self
.
pulseView
=
nil
}
pulseColor
=
.
whiteColor
()
}
}
Source/MaterialButton.swift
View file @
b1aeb2d5
...
...
@@ -19,19 +19,18 @@
import
UIKit
public
class
MaterialButton
:
UIButton
{
private
lazy
var
pulseView
:
UIView
=
UIView
()
internal
lazy
var
backgroundColorView
:
UIView
=
UIView
()
public
var
color
:
UIColor
?
public
var
pulseColor
:
UIColor
?
internal
var
pulseView
:
UIView
?
internal
var
verticalLine
:
UIView
?
internal
var
horizontalLine
:
UIView
?
internal
var
backgroundColorView
:
UIView
?
/**
:name: init
*/
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
prepareView
()
prepareShadow
()
}
...
...
@@ -40,6 +39,7 @@ public class MaterialButton : UIButton {
*/
public
required
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
prepareView
()
prepareShadow
()
}
...
...
@@ -50,13 +50,6 @@ public class MaterialButton : UIButton {
self
.
init
(
frame
:
CGRectZero
)
}
func
prepareShadow
()
{
layer
.
shadowOffset
=
CGSizeMake
(
1
,
1
)
layer
.
shadowColor
=
UIColor
.
blackColor
()
.
CGColor
layer
.
shadowOpacity
=
0.5
layer
.
shadowRadius
=
5
}
/**
:name: touchesBegan
*/
...
...
@@ -83,21 +76,78 @@ public class MaterialButton : UIButton {
removePulse
()
}
/**
:name: drawRect
*/
final
public
override
func
drawRect
(
rect
:
CGRect
)
{
prepareContext
(
rect
)
prepareButton
()
}
/**
:name: prepareButton
*/
public
func
prepareButton
()
{
prepareBackgroundColorView
()
}
//
// :name: prepareView
//
internal
func
prepareView
()
{
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
}
//
// :name: prepareShadow
//
internal
func
prepareShadow
()
{
layer
.
shadowOffset
=
CGSizeMake
(
1
,
1
)
layer
.
shadowColor
=
UIColor
.
blackColor
()
.
CGColor
layer
.
shadowOpacity
=
0.5
layer
.
shadowRadius
=
5
}
//
// :name: prepareContext
//
internal
func
prepareContext
(
rect
:
CGRect
)
{
let
context
=
UIGraphicsGetCurrentContext
()
CGContextSaveGState
(
context
);
CGContextAddEllipseInRect
(
context
,
rect
)
CGContextSetFillColorWithColor
(
context
,
UIColor
.
clearColor
()
.
CGColor
)
CGContextFillPath
(
context
)
CGContextRestoreGState
(
context
);
}
//
// :name: prepareBackgroundColorView
//
// We need this view so we can use the masksToBounds
// so the pulse doesn't animate off the button
internal
func
prepareBackgroundColorView
()
{
backgroundColorView
.
frame
=
bounds
backgroundColorView
.
layer
.
cornerRadius
=
bounds
.
width
/
2.0
backgroundColorView
.
backgroundColor
=
color
backgroundColorView
.
layer
.
masksToBounds
=
true
backgroundColorView
.
userInteractionEnabled
=
false
insertSubview
(
backgroundColorView
,
atIndex
:
0
)
}
//
// :name: pulseTouches
//
internal
func
pulseTouches
(
touches
:
NSSet
)
{
let
touch
=
touches
.
allObjects
.
last
as!
UITouch
let
touchLocation
=
touch
.
locationInView
(
self
)
pulseView
=
UIView
()
pulseView
!.
frame
=
CGRectMake
(
0
,
0
,
bounds
.
width
,
bounds
.
height
)
pulseView
!.
layer
.
cornerRadius
=
bounds
.
width
/
2.0
pulseView
!.
center
=
touchLocation
pulseView
!.
backgroundColor
=
pulseColor
!.
colorWithAlphaComponent
(
0.5
)
backgroundColorView
!.
addSubview
(
pulseView
!
)
pulseView
.
frame
=
CGRectMake
(
0
,
0
,
bounds
.
width
,
bounds
.
height
)
pulseView
.
layer
.
cornerRadius
=
bounds
.
width
/
2.0
pulseView
.
center
=
touchLocation
pulseView
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
0.5
)
backgroundColorView
.
addSubview
(
pulseView
)
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
self
.
pulseView
!
.
transform
=
CGAffineTransformMakeScale
(
3
,
3
)
self
.
pulseView
.
transform
=
CGAffineTransformMakeScale
(
3
,
3
)
self
.
transform
=
CGAffineTransformMakeScale
(
1.1
,
1.1
)
},
completion
:
nil
...
...
@@ -126,11 +176,10 @@ public class MaterialButton : UIButton {
internal
func
removePulse
()
{
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
_
in
self
.
pulseView
?
.
alpha
=
0.0
self
.
pulseView
.
alpha
=
0.0
}
)
{
_
in
self
.
pulseView
?
.
removeFromSuperview
()
self
.
pulseView
=
nil
self
.
pulseView
.
removeFromSuperview
()
}
}
}
Source/RaisedButton.swift
View file @
b1aeb2d5
...
...
@@ -19,112 +19,19 @@
import
UIKit
public
class
RaisedButton
:
MaterialButton
{
public
override
func
drawRect
(
rect
:
CGRect
)
{
setupContext
(
rect
)
setupBackgroundColorView
()
}
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
initialize
()
applyShadow
()
}
public
required
override
init
(
frame
:
CGRect
)
{
public
required
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
initialize
()
applyShadow
()
}
func
initialize
()
{
color
=
UIColor
.
redColor
()
backgroundColorView
=
UIView
()
pulseColor
=
UIColor
.
whiteColor
()
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
}
public
override
func
touchesBegan
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
super
.
touchesBegan
(
touches
,
withEvent
:
event
)
pulseTouches
(
touches
)
}
public
override
func
touchesEnded
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
super
.
touchesEnded
(
touches
,
withEvent
:
event
)
shrink
()
removePulse
()
}
public
override
func
touchesCancelled
(
touches
:
Set
<
NSObject
>!
,
withEvent
event
:
UIEvent
!
)
{
super
.
touchesCancelled
(
touches
,
withEvent
:
event
)
shrink
()
removePulse
()
}
private
func
setupContext
(
rect
:
CGRect
)
{
let
context
=
UIGraphicsGetCurrentContext
()
CGContextSaveGState
(
context
);
CGContextSetFillColorWithColor
(
context
,
UIColor
.
clearColor
()
.
CGColor
)
CGContextFillPath
(
context
)
CGContextRestoreGState
(
context
);
}
// We need this view so we can use the masksToBounds
// so the pulse doesn't animate off the button
private
func
setupBackgroundColorView
()
{
backgroundColorView
!.
frame
=
self
.
bounds
backgroundColorView
!.
layer
.
cornerRadius
=
3.0
backgroundColorView
!.
backgroundColor
=
color
!
backgroundColorView
!.
layer
.
masksToBounds
=
true
backgroundColorView
!.
userInteractionEnabled
=
false
self
.
insertSubview
(
backgroundColorView
!
,
atIndex
:
0
)
}
private
func
applyShadow
()
{
layer
.
shadowOffset
=
CGSizeMake
(
1
,
1
)
layer
.
shadowColor
=
UIColor
.
blackColor
()
.
CGColor
layer
.
shadowOpacity
=
0.5
layer
.
shadowRadius
=
5
}
private
func
pulseTouches
(
touches
:
NSSet
)
{
let
touch
=
touches
.
allObjects
.
last
as!
UITouch
let
touchLocation
=
touch
.
locationInView
(
self
)
pulseView
=
UIView
()
pulseView
!.
frame
=
CGRectMake
(
0
,
0
,
self
.
bounds
.
size
.
height
,
self
.
bounds
.
size
.
height
)
pulseView
!.
layer
.
cornerRadius
=
bounds
.
height
/
2.0
pulseView
!.
center
=
touchLocation
pulseView
!.
backgroundColor
=
pulseColor
!.
colorWithAlphaComponent
(
0.5
)
backgroundColorView
!.
addSubview
(
pulseView
!
)
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
self
.
pulseView
!.
transform
=
CGAffineTransformMakeScale
(
10
,
10
)
self
.
transform
=
CGAffineTransformMakeScale
(
1.05
,
1.1
)
},
completion
:
nil
)
}
private
func
shrink
()
{
UIView
.
animateWithDuration
(
0.3
,
delay
:
0.0
,
usingSpringWithDamping
:
0.2
,
initialSpringVelocity
:
10
,
options
:
nil
,
animations
:
{
self
.
transform
=
CGAffineTransformIdentity
},
completion
:
nil
)
}
private
func
removePulse
()
{
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
()
->
Void
in
self
.
pulseView
!.
alpha
=
0.0
})
{
_
in
self
.
pulseView
!.
removeFromSuperview
()
self
.
pulseView
=
nil
}
color
=
.
redColor
()
pulseColor
=
.
whiteColor
()
}
}
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