Commit e89deeef by Daniel Dahan

updated pulse animation

parent 82be6f7f
...@@ -25,6 +25,11 @@ public class MaterialPulseView: MaterialView { ...@@ -25,6 +25,11 @@ public class MaterialPulseView: MaterialView {
internal lazy var pulseLayer: CAShapeLayer = CAShapeLayer() internal lazy var pulseLayer: CAShapeLayer = CAShapeLayer()
/** /**
:name: pulseColor
*/
public var pulseColor: UIColor?
/**
:name: init :name: init
*/ */
public convenience init() { public convenience init() {
...@@ -40,16 +45,17 @@ public class MaterialPulseView: MaterialView { ...@@ -40,16 +45,17 @@ public class MaterialPulseView: MaterialView {
if nil != visualLayer.presentationLayer()?.hitTest(point) { if nil != visualLayer.presentationLayer()?.hitTest(point) {
CATransaction.begin() CATransaction.begin()
CATransaction.setAnimationDuration(0) CATransaction.setAnimationDuration(0)
pulseLayer.hidden = false
pulseLayer.position = point pulseLayer.position = point
pulseLayer.frame = CGRectMake(0, 0, width, height) let w: CGFloat = width / 2
pulseLayer.cornerRadius = visualLayer.cornerRadius pulseLayer.bounds = CGRectMake(0, 0, w, w)
pulseLayer.cornerRadius = w
CATransaction.commit() CATransaction.commit()
CATransaction.begin() CATransaction.begin()
CATransaction.setAnimationDuration(0.3) CATransaction.setAnimationDuration(0.3)
pulseLayer.hidden = false
pulseLayer.transform = CATransform3DMakeScale(3, 3, 3) pulseLayer.transform = CATransform3DMakeScale(3, 3, 3)
visualLayer.transform = CATransform3DMakeScale(1.1, 1.1, 1.1) visualLayer.transform = CATransform3DMakeScale(1.05, 1.05, 1.05)
CATransaction.commit() CATransaction.commit()
} }
} }
...@@ -81,6 +87,7 @@ public class MaterialPulseView: MaterialView { ...@@ -81,6 +87,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
pulseColor = MaterialColor.white
} }
// //
...@@ -102,7 +109,7 @@ public class MaterialPulseView: MaterialView { ...@@ -102,7 +109,7 @@ public class MaterialPulseView: MaterialView {
// pulseLayer // pulseLayer
pulseLayer.hidden = true pulseLayer.hidden = true
pulseLayer.backgroundColor = MaterialColor.white.colorWithAlphaComponent(0.5).CGColor pulseLayer.backgroundColor = pulseColor?.colorWithAlphaComponent(0.5).CGColor
visualLayer.addSublayer(pulseLayer) visualLayer.addSublayer(pulseLayer)
} }
} }
...@@ -110,7 +110,7 @@ public class MaterialView: UIView { ...@@ -110,7 +110,7 @@ public class MaterialView: UIView {
*/ */
public var width: CGFloat { public var width: CGFloat {
get { get {
return layer.frame.size.width return visualLayer.frame.size.width
} }
set(value) { set(value) {
layer.frame.size.width = value layer.frame.size.width = value
...@@ -124,7 +124,7 @@ public class MaterialView: UIView { ...@@ -124,7 +124,7 @@ public class MaterialView: UIView {
*/ */
public var height: CGFloat { public var height: CGFloat {
get { get {
return layer.frame.size.height return visualLayer.frame.size.height
} }
set(value) { set(value) {
layer.frame.size.height = value layer.frame.size.height = value
...@@ -290,7 +290,7 @@ public class MaterialView: UIView { ...@@ -290,7 +290,7 @@ public class MaterialView: UIView {
borderColor = MaterialTheme.view.bordercolor borderColor = MaterialTheme.view.bordercolor
// visualLayer // visualLayer
visualLayer.frame = CGRectMake(0, 0, width, height) visualLayer.bounds = CGRectMake(0, 0, width, height)
layer.addSublayer(visualLayer) layer.addSublayer(visualLayer)
} }
......
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