Commit 80a0075e by Daniel Dahan

updated MaterialPulseView and MaterialButton pulse animation

parent 609842a7
...@@ -363,20 +363,16 @@ public class MaterialButton : UIButton { ...@@ -363,20 +363,16 @@ public class MaterialButton : UIButton {
if true == layer.containsPoint(point) { if true == layer.containsPoint(point) {
let s: CGFloat = (width < height ? height : width) / 2 let s: CGFloat = (width < height ? height : width) / 2
let f: CGFloat = 3 let f: CGFloat = 3
var v: CGFloat = s / f let v: CGFloat = s / f
let d: CGFloat = 2 * f
MaterialAnimation.animationDisabled({ MaterialAnimation.animationDisabled({
self.pulseLayer.hidden = false self.pulseLayer.hidden = false
self.pulseLayer.bounds = CGRectMake(0, 0, v, v) self.pulseLayer.bounds = CGRectMake(0, 0, v, v)
self.pulseLayer.position = point self.pulseLayer.position = point
self.pulseLayer.cornerRadius = s / 6 self.pulseLayer.cornerRadius = s / d
}) })
v = 2 * f
MaterialAnimation.animationWithDuration(0.4, animations: {
self.pulseLayer.transform = CATransform3DMakeScale(v, v, v)
})
MaterialAnimation.animationWithDuration(0.25, animations: { MaterialAnimation.animationWithDuration(0.25, animations: {
self.pulseLayer.transform = CATransform3DMakeScale(d, d, d)
self.layer.transform = CATransform3DMakeScale(1.05, 1.05, 1.05) self.layer.transform = CATransform3DMakeScale(1.05, 1.05, 1.05)
}) })
} }
......
...@@ -20,14 +20,23 @@ import UIKit ...@@ -20,14 +20,23 @@ import UIKit
public class MaterialLayer : CAShapeLayer { public class MaterialLayer : CAShapeLayer {
/**
:name: init
*/
public required init?(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
} }
/**
:name: init
*/
public override init(layer: AnyObject) { public override init(layer: AnyObject) {
super.init(layer: layer) super.init(layer: layer)
} }
/**
:name: init
*/
public override init() { public override init() {
super.init() super.init()
} }
......
...@@ -58,20 +58,16 @@ public class MaterialPulseView : MaterialView { ...@@ -58,20 +58,16 @@ public class MaterialPulseView : MaterialView {
if true == layer.containsPoint(point) { if true == layer.containsPoint(point) {
let s: CGFloat = (width < height ? height : width) / 2 let s: CGFloat = (width < height ? height : width) / 2
let f: CGFloat = 3 let f: CGFloat = 3
var v: CGFloat = s / f let v: CGFloat = s / f
let d: CGFloat = 2 * f
MaterialAnimation.animationDisabled({ MaterialAnimation.animationDisabled({
self.pulseLayer.hidden = false self.pulseLayer.hidden = false
self.pulseLayer.bounds = CGRectMake(0, 0, v, v) self.pulseLayer.bounds = CGRectMake(0, 0, v, v)
self.pulseLayer.position = point self.pulseLayer.position = point
self.pulseLayer.cornerRadius = s / 6 self.pulseLayer.cornerRadius = s / d
}) })
v = 2 * f
MaterialAnimation.animationWithDuration(0.4, animations: {
self.pulseLayer.transform = CATransform3DMakeScale(v, v, v)
})
MaterialAnimation.animationWithDuration(0.25, animations: { MaterialAnimation.animationWithDuration(0.25, animations: {
self.pulseLayer.transform = CATransform3DMakeScale(d, d, d)
self.layer.transform = CATransform3DMakeScale(1.05, 1.05, 1.05) self.layer.transform = CATransform3DMakeScale(1.05, 1.05, 1.05)
}) })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment