Pulse animation for iOS written with Swift.

Overview

Pulsator

Badge w/ Version Carthage compatible License Twitter

Pulse animation for iOS written with Swift.

Great For:

  • Pulses of Bluetooth, BLE, beacons (iBeacon), etc.
  • Map Annotations

Installation

CocoaPods

Add into your Podfile.

pod "Pulsator"

Then $ pod install

Carthage

Add into your Cartfile.

github "shu223/Pulsator"

Then $ carthage update

How to use

Just 3 lines!

Initiate and add to your view's layer, then call start!

let pulsator = Pulsator()
view.layer.addSublayer(pulsator)
pulsator.start()

Customizations

Number of Pulses

Use numPulse property.

pulsator.numPulse = 3

Radius

Use radius property.

pulsator.radius = 240.0

Color

Just set the backgroundColor property.

pulsator.backgroundColor = UIColor(red: 1, green: 1, blue: 0, alpha: 1).cgColor

Animation Duration

Use following properties

  • animationDuration : duration for each pulse
  • pulseInterval : interval between pulses

Easing

You can set the timingFunction property.

Repeat

Use repeatCount property.

Demo

You can try to change the radius, backgroundColor or other properties with the demo app.

  • Example/PulsatorDemo.xcodeproj

macOS support

Add into your Podfile, then run pod install.

platform :osx, '10.9'

target 'Pulsator' do
  use_frameworks!
  pod "Pulsator"
end

The usage is same as iOS.

let pulsator = Pulsator()
view.layer?.addSublayer(pulsator)
pulsator.start()

Objective-C version

There is an ObjC version, but it's not maintained now.

You can use Pulsator also with Objective-C.

#import "Pulsator-Swift.h"

Author

Shuichi Tsutsumi

iOS freelancer in Japan. Welcome works from abroad!

Support via PayPal
Comments
  • Pulsator stops working after presenting a viewcontroller then dismissing it

    Pulsator stops working after presenting a viewcontroller then dismissing it

    Hello,

    I'm encountering an issue where if I have a pulsator started on a viewcontroller, then I present another viewcontroller and dismiss it, the pulse animation no longer shows. I forked the demo project to demonstrate the problem here.

    Just click the button to present the viewcontroller, then dismiss it and you can see that the pulse stops. Any suggestions on how to fix this?

    opened by DeepAnchor 6
  • Carthage build fails

    Carthage build fails

    Carthage fails for some reason with the following error:

    *** Building scheme "Pulsator" in Pulsator.xcodeproj Failed to write to /Users/geddoff/Git/tmarkovski/indyapp/Carthage/Build/Mac/Pulsator.framework: Error Domain=NSCocoaErrorDomain Code=260 "The file “Pulsator.framework” couldn’t be opened because there is no such file." UserInfo={NSURL=file:///Users/geddoff/Library/Caches/org.carthage.CarthageKit/DerivedData/9.3_9E145/Pulsator/0.5.1/Build/Intermediates.noindex/ArchiveIntermediates/Pulsator/BuildProductsPath/Release-iphoneos/Pulsator.framework, NSFilePath=/Users/geddoff/Library/Caches/org.carthage.CarthageKit/DerivedData/9.3_9E145/Pulsator/0.5.1/Build/Intermediates.noindex/ArchiveIntermediates/Pulsator/BuildProductsPath/Release-iphoneos/Pulsator.framework, NSUnderlyingError=0x7fd8bec97b50 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

    I simply added the entry to the Cartfile. Any ideas?

    opened by tmarkovski 5
  • Can't get the pulse positioned behind a button...

    Can't get the pulse positioned behind a button...

    Also setting pulsator.position makes it disappear completely?

           pulsator.position = self.view.center
            pulsator.numPulse = 5
            pulsator.radius = 70
            pulsator.repeatCount = .greatestFiniteMagnitude
            pulsator.animationDuration = 3
            pulsator.backgroundColor = UIColor(red: 0, green: 0.755, blue: 0.756, alpha: 1).cgColor
            button.layer.insertSublayer(pulsator, below: button.layer)
            pulsator.start()
    
    opened by designfrontier 5
  • Pulsator animaton does not appear

    Pulsator animaton does not appear

    my code: ` let pulsator = Pulsator() override func viewDidLoad() { super.viewDidLoad() shoppieImage.layer.superlayer!.insertSublayer(pulsator, below: shoppieImage.layer) pulsator.numPulse = 1 pulsator.animationDuration = 1 pulsator.repeatCount = 0 pulsator.pulseInterval = 0.25 pulsator.backgroundColor = ShopXStyle.yellowColor.cgColor pulsator.radius = 200 pulsator.name = "pulsator" pulsator.start() }

    override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() view.layer.layoutIfNeeded() pulsator.position = shoppieImage.center }`

    opened by minaMagedNaeem 4
  • Swift 4.2 migration and pod spec updates

    Swift 4.2 migration and pod spec updates

    • Swift 4.2 migration on source and example project
    • Removed .swift-version file in favour of using s.swift_version in pod spec
    • Incremented s.version patch number for next cocoa pod release
    opened by sean-howard 4
  • Not visible until view disappears/reappears

    Not visible until view disappears/reappears

    Pulsator is not visible until I close the app and reopen it (causing viewDidLayoutSubviews to trigger). No matter if I call centerPulsator(), force layouting subviews upon load etc. What could be the problem?

    import Foundation
    import Pulsator
    
    class TestView: UIViewController {
    
        var icon: UIImage?
        var message: String?
        var buttonTitle: String?
    
        lazy var iconView: UIImageView = { [unowned self] in
            let view = UIImageView()
    
            view.backgroundColor = UIColor.clearColor()
            view.image = self.icon
    
            return view
        }()
    
        lazy var pulsator: Pulsator = { [unowned self] in
            let pulsator = Pulsator()
    
            pulsator.numPulse = 3
            pulsator.radius = 100
            pulsator.backgroundColor = UIColor.redColor()
    
            pulsator.position = self.iconView.layer.position
    
            return pulsator
        }()
    
        lazy var messageLabel: UILabel = { [unowned self] in
            let label = UILabel()
    
            label.textColor = UIColor.darkGrayColor()
            label.font = UIFont.systemFontOfSize(17)
            label.adjustsFontSizeToFitWidth = true
            label.numberOfLines = 0
            label.minimumScaleFactor = 0.5
            label.textAlignment = .Center
    
            label.text = self.message
    
            return label
        }()
    
        lazy var settings: UIButton = { [unowned self] in
            let button = UIButton()
    
            button.backgroundColor = UIColor.redColor()
            button.setTitleColor(UIColor.whiteColor(), forState: .Normal)
            button.setTitle(self.buttonTitle, forState: .Normal)
    
            button.addTarget(self, action: #selector(openSystemSettings), forControlEvents: .TouchUpInside)
    
            return button
        }()
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            view.backgroundColor = UIColor.whiteColor()
    
            [iconView, messageLabel, settings].forEach {
                view.addSubview($0)
                $0.translatesAutoresizingMaskIntoConstraints = false
                view.bringSubviewToFront($0)
            }
    
            iconView.layer.superlayer?.insertSublayer(pulsator, below: iconView.layer)
    
            setupConstraints()
    
            pulsator.start()
            centerPulsator()
        }
    
        override func viewDidLayoutSubviews() {
            super.viewDidLayoutSubviews()
            centerPulsator()
        }
    
        func centerPulsator() {
            iconView.layer.layoutIfNeeded()
            pulsator.position = iconView.layer.position
        }
    
        func openSystemSettings() {
            UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!)
        }
    
        func setupConstraints() {
    
            // Icon and pulsator
            for attribute: NSLayoutAttribute in [.Width, .Height] {
                view.addConstraint(NSLayoutConstraint(item: iconView, attribute: attribute, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: 70))
            }
            for attribute: NSLayoutAttribute in [.CenterX, .CenterY] {
                view.addConstraint(NSLayoutConstraint(item: iconView, attribute: attribute, relatedBy: .Equal, toItem: view, attribute: attribute, multiplier: 1, constant: 0))
            }
    
            // Settings Button
            view.addConstraint(NSLayoutConstraint(item: settings, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: 50))
            for attribute: NSLayoutAttribute in [.Left, .Right, .Bottom] {
                view.addConstraint(NSLayoutConstraint(item: settings, attribute: attribute, relatedBy: .Equal, toItem: view, attribute: attribute, multiplier: 1, constant: 0))
            }
    
            // Message Label
            view.addConstraint(NSLayoutConstraint(item: messageLabel, attribute: .Bottom, relatedBy: .Equal, toItem: settings, attribute: .Top, multiplier: 1, constant: -40))
            view.addConstraint(NSLayoutConstraint(item: messageLabel, attribute: .Left, relatedBy: .Equal, toItem: view, attribute: .Left, multiplier: 1, constant: 20))
            view.addConstraint(NSLayoutConstraint(item: messageLabel, attribute: .Right, relatedBy: .Equal, toItem: view, attribute: .Right, multiplier: 1, constant: -20))
        }
    }
    
    opened by n1mda 4
  • Made default position center of super layer

    Made default position center of super layer

    I noticed in a few of the issues(#17) as well as my own experience, that the expected behavior of the Pulsator is to be centered in the superlayer, as opposed to the layer being at the superlayer's origin. I made a few changes to make the center of the superlayer the default position. The user can set a new property "autoCenter" to false if they wish to position it in a different manner. You may or may not disagree with this behavior. I also corrected a typo to a method name.

    opened by musicisamiracle 3
  • Dismiss Pulsator and CGPoint position not working.

    Dismiss Pulsator and CGPoint position not working.

    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?

    opened by HackShitUp 3
  • Pulsator in Custom Map Annotation

    Pulsator in Custom Map Annotation

    Hi,

    I was to trying add Pulsator into my project, but the annotation cant play pulse, what I'm doing wrong? My code below is :

    #annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "pin")
    annotationView!.canShowCallout = true
    annotationView!.image = UIImage(named: "cars2x")
    
    annotationView!.layer.superlayer?.insertSublayer(pulsator, below: annotationView!.layer)
    pulsator.numPulse = 3
    pulsator.radius = 240.0
    pulsator.start()
    

    The code is ok, no found errors, but pulse can't show up :/

    opened by mrsnax 3
  • pulsator not show?

    pulsator not show?

    hi, i add pulsator instance to avatar(UIImageView) in viewDidLoad then start, but i can not see pulsator, can u help?

    DispatchQueue.main.async {
                let pulsator = Pulsator()
                pulsator.position = self.avatar.center
                self.avatar.layer.addSublayer(pulsator)
                pulsator.start()
            }
    
    opened by fukemy 2
  • Adding via SPM does not work in Xcode 11.3.1

    Adding via SPM does not work in Xcode 11.3.1

    Any reason the Package.swift starts with // swift-tools-version:5.2?

    Because of this the package cannot be added via Xcode 11.3.1. I think there is nothing Swift 5.2. specific in the source code.

    opened by igorkulman 2
  • Enable delay before animation starts as TimeInterval

    Enable delay before animation starts as TimeInterval

    Added feature to delay animation after calling start(). This also works in case of minimising app and reopening it. Even if we would call start() for several Pulsators with randomly delayed code, after app would receive applicationWillBecomeActive call, all pulsations would synchronise.

    opened by mister-giga 0
  • Pulse is not centered to view

    Pulse is not centered to view

    Hi, I'm trying to get a nice pulse below a round avatar view. The UIImageView itself is a rectangle spanning the entire screen, its image is a circle with aspect fit. When I add the pulsator view like this:

        let pulsator = Pulsator()
        pulsator.radius = 500
        pulsator.numPulse = 3
        pulsator.pulseInterval = 3
        pulsator.animationDuration = 5
        pulsator.backgroundColor = UIColor(red: 0, green: 0.623, blue: 0.890, alpha: 0.3).cgColor
        self.avatarImageView.addSublayer(pulsator)
        pulsator.start()
    

    It works but the pulse comes from the top left of the UIImageView. I want it to spawn pulses from the center of the image, which is also the center of the UIImageView itself. How can I change the pulsator's position? Or how can I center it properly to the view?

    opened by kevinluscii 1
  • Pulsator has no member isReversed

    Pulsator has no member isReversed

    Up until before I migrated my project to Swift 5, this worked fine: var pulse = Pulsator() pulse.isReversed = true

    However now it doesn't. Does anyone have any idea why? Or what I should do about it?

    opened by jordan-romeroporter-earnin 0
  • NavigationBar bar button customView doesn't work properly.

    NavigationBar bar button customView doesn't work properly.

    For the first time it works when the view controller is opened. See the below screenshot, There is a NavigationController embed in.

    image

    After I click a subpage, which is under the NavigationController and then swipe back to the current page. It doesn't work correctly. After I performSegue and swipe back to the current page. Here is another screenshot,

    image

    Could you take a look please?

    opened by MrFuFuFu 0
  • square pulse in google map?

    square pulse in google map?

    Can you help?

    let markerView = UIImageView(image: GMSMarker.markerImage(with: UIColor.red))
                marker.iconView = markerView
    
    let pulsator = Pulsator()
                        pulsator.numPulse = 3
                        pulsator.radius = 240.0
                        pulsator.repeatCount = .infinity
                        marker.iconView?.layer.insertSublayer(pulsator, above: marker.iconView?.layer)
                        pulsator.position = (marker.iconView?.layer.position)!
                        pulsator.start()
    
    opened by fukemy 1
Releases(0.6.0)
Owner
Shuichi Tsutsumi
Freelance iOS Programmer
Shuichi Tsutsumi
Simple Interface Core Animation. Run type-safe animation sequencially or parallelly

Simple Interface Core Animation Sica can execute various animations sequentially or parallelly. Features Animation with duration and delay parallel /

CATS Open Source Softwares 1k Nov 10, 2022
An experiment for using SwiftUI's custom timing Animation to create an orbital-like animation.

Orbital-SwiftUI-Animation An experiment for using SwiftUI's custom timing curve to create an orbital-like animation. How it looks: How it works: Apply

Mostafa Abdellateef 7 Jan 2, 2023
SwiftUI-Text-Animation-Library - Text animation library for SwiftUI

⚠️ This repository is under construction. SwiftUI Text Animation Library Make yo

null 28 Jan 8, 2023
Swiftui-animation-observer - Track SwiftUI animation progress and completion via callbacks

SwiftUI Animation Observer Track SwiftUI animation progress and completion via c

Gordan Glavaš 9 Nov 5, 2022
Gemini is rich scroll based animation framework for iOS, written in Swift.

Overview What is the Gemini? Gemini is rich scroll based animation framework for iOS, written in Swift. You can easily use GeminiCollectionView, which

Shohei Yokoyama 3k Dec 27, 2022
SYBlinkAnimationKit is a blink effect animation framework for iOS, written in Swift.

SYBlinkAnimationKit is a blink effect animation framework for iOS, written in Swift ?? Demo There are 5 types of animation for component. border borde

Shohei Yokoyama 126 Oct 28, 2021
TTouchAnimatedButton is a simple and flexible animation component fully written in Swift

TTouchAnimatedButton is a simple and flexible animation component fully written in Swift. TTouchAnimatedButton is developed to make user feel button click becomes more vivid and realistic.

Nguyen Duc Thinh 2 Aug 18, 2022
A DSL to make animation easy on iOS with Swift.

This project is highly inspired by JHChainableAnimations, If you project is developed with Objective-C, use JHChainableAnimations instead. With DKChai

Draven 1.9k Dec 9, 2022
Swift animation library for iOS, tvOS and macOS.

anim is an animation library written in Swift with a simple, declarative API in mind. // moves box to 100,100 with default settings anim { self.bo

Onur Ersel 555 Dec 12, 2022
Animation library for iOS in Swift

TweenKit TweenKit is a powerful animation library that allows you to animate (or 'tween') anything. TweenKit's animations are also scrubbable, perfect

Steve Barnegren 1.3k Dec 18, 2022
Easy animation library on iOS with Swift2

Cheetah Cheetah is an animation utility on iOS with Swift. Cheetah can animate any properties since Cheetah uses simple CADisplayLink run loop to chan

Suguru Namura 592 Dec 6, 2022
A radical & elegant animation library for iOS.

Installation • Usage • Debugging • Animatable Properties • License Dance is a powerful and straightforward animation framework built upon the new UIVi

Saoud Rizwan 648 Dec 14, 2022
An extensible iOS and OS X animation library, useful for physics-based interactions.

Pop is an extensible animation engine for iOS, tvOS, and OS X. In addition to basic static animations, it supports spring and decay dynamic animations

Meta Archive 19.8k Dec 28, 2022
iOS Component for creating a pulsing animation.

PulsingHalo PulsingHalo has been discontinued, and is no longer being maintained. Please check out Pulsator which is the new version of this written w

Shuichi Tsutsumi 1.8k Dec 29, 2022
Widgets iOS 14 animation with 3D and dynamic shadow. Customisable transform and duration.

SPPerspective About Animatable widgets from iOS 14. Same animation for transform and shadow. Customisable duration, perspective and shadow also. For v

Ivan Vorobei 290 Dec 29, 2022
This library is for adding animation to iOS tabbar items, which is inherited from UITabBarController.

This library is for adding animation to iOS tabbar items, which is inherited from UITabBarController. Installation Just add the Sources folder to your

Yuşa Doğru 162 Jan 6, 2023
Awesome IOS Styling with SwiftUI, Animation, Effects, Gesture ⭐️

Awesome SwiftUI Styling with SwiftUI ⭐️ This repository is dedicated to IOS styling using SwiftUI. (often using Other Libraries.) I started collecting

SeungYeub Baek 1 Apr 5, 2022
Wave is a spring-based animation engine for iOS that makes it easy to create fluid, interruptible animations that feel great.

Wave is a spring-based animation engine for iOS and iPadOS. It makes it easy to create fluid, interactive, and interruptible animations that feel great.

Janum Trivedi 1.2k Jan 8, 2023