I am struggling with the strange issue like when I am adding scale transformation to any layer, it doesn't animated from the center. It does from origin.
func addSquareBorderLayer() {
borderLayer = CAShapeLayer()
let rect = CGRect(x: spotlight!.frame.origin.x, y: spotlight!.frame.origin.y, width: spotlight!.frame.width, height: spotlight!.frame.height)
borderLayer?.path = UIBezierPath(roundedRect: rect, cornerRadius: spotlight!.cornerRadius).cgPath
borderLayer?.strokeColor = UIColor(red: 91/255, green: 186/255, blue: 162/255, alpha: 1).cgColor //ColorRGB(91, 186, 162)
borderLayer?.lineWidth = spotlight!.cornerRadius
borderLayer?.fillColor = UIColor.clear.cgColor
layer.addSublayer(borderLayer!)
animatePulsatingLayer(pulsatingLayer: layer)
}
private func animatePulsatingLayer(pulsatingLayer : CALayer) {
let animation = CABasicAnimation(keyPath: "transform.scale")
animation.duration = 0.5
animation.repeatCount = .greatestFiniteMagnitude
animation.autoreverses = true
animation.fromValue = 1
animation.toValue = 1.05
pulsatingLayer.add(animation, forKey: "pulsing")
}
Can anybody please help?
Refernce to what's happening: https://www.dropbox.com/s/0hqdrrv310du7vz/mo.mov?dl=0