Pulse animations with 3 lines on iOS
“Pulsator” is an OSS which enable to add pulse animations easily for iOS.
https://github.com/shu223/pulsator
It’s good for indicating:
- locations on map
- beacons of iBeacon
- Bluetooth Low Energy (BTLE) devices
- or other “Radio Wave” related devices
It can be installed in an instant, so I use it on not only my client works, but also small prototypes, or works in hackathons.
It’s written in Swift, and the license is MIT.
How to use?
It can be used with only 3 lines of code.
1. Initialize
let pulsator = Pulsator()
2. Add to your view’s layer
view.layer.addSublayer(pulsator)
3. Start animating
pulsator.start()
Customizations / Demo
You can customize the radius, color, number of pulses, etc. Please refer to the demo project or Playground which are in the repository.
Demo
- Example/PulsatorDemo.xcodeproj
Playground
- Pulsator.playground
Browser Demo
You can try also on browsers.
Installation
It supports CocoaPods and Carthage.
CocoaPods
Add into your Podfile.
pod “Pulsator”
Carthage
Add into your Cartfile.
github “shu223/Pulsator”
Showcase
I used the Objective-C version of this library “PulsingHalo” in many client works, open source projects and so on.
WHILL
Moff
BONX
Waves which indicate “talking”
iOS-9-Sampler
Indicates the locations and strengths of forth touches.
Inside of Pulsator
Pulsator is implemented using Core Animation.
CAReplicatorLayer
Pulsator is a subclass of CAReplicatorLayer.
public class Pulsator: CAReplicatorLayer
CAReplicatorLayer is a layer which creates `instanceCount` copies of its sublayers, so Pulsator uses it to generate multiple pulses.
CAAnimationGroup
The animation for each pulse consists of scale animation + opacity animation, and Pulsator use those animations combining with CAAnimationGroup.
let scaleAnimation = CABasicAnimation(keyPath: “transform.scale.xy”)
// some setup
let opacityAnimation = CAKeyframeAnimation(keyPath: “opacity”)
// some setup
animationGroup = CAAnimationGroup()
animationGroup.animations = [scaleAnimation, opacityAnimation]
About me
I’m an iOS freelancer in Japan, welcome works from abroad.
You can check my past works here: My Profile Summary — Medium
Other contacts: