Closed HackShitUp closed 3 years ago
Same issue for me too
@andrewfashion have you figured it out yet???
Here's how I got it working...
1) Declare a Pulsator on MyViewController
:
let pulsator = Pulsator()
2) In viewDidLoad
, set your pulsator
properties what view you want to add it to, etc.
yourImageView.layer.superlayer?.insertSublayer(pulsator, below: yourImageView.layer)
pulsator.numPulse = 3
pulsator.backgroundColor = UIColor.red.cgColor
pulsator.radius = containerView.bounds.width / 2
This is why mine wasn't centering in the imageView
3) If you don't have viewDidLayoutSubviews
configured, do so...
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
view.layer.layoutIfNeeded()
pulsator.position = yourImageView.center
}
4) Wherever you want it to start pulsing, then call pulsator.start()
. Wherever you want it to stop, call pulsator.stop()
There's two things that I can't seem to get working or can't figure out. First, the .position protocol doesn't recognize the CGPoint value and is always set to the upper left corner of the screen. Next, how do I dismiss the pulsator after starting it?