Giter VIP home page Giter VIP logo

pulsator's Introduction

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
<iframe src="https://appetize.io/embed/45kwjngp1xud45eeqhxqy8qqew?device=iphone6s&scale=75&autoplay=false&orientation=portrait&deviceColor=black" width="312px" height="653px" frameborder="0" scrolling="no"></iframe>

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

pulsator's People

Contributors

ajacquelin avatar andynetvir avatar brightsider avatar creitz avatar dealforest avatar kittenyang avatar sean-howard avatar shu223 avatar woodencoder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pulsator's Issues

Use of unresolved identifier 'Pulsator'

Hey guys,

I've been trying for two days to get Pulsator to work, but no matter what I do, I keep getting the Use of unresolved identifier 'Pulsator' error.
I have a simple Podfile:

platform :ios, '10.0'
use_frameworks!

target 'JumpingJacksAlarm' do
    pod 'Pulsator', '~> 0.3.0'
end

and pod install reports success. I also tried pod update, project clean, restarts, reinstalls, and pretty much any suggestions I was able to find.

I would really appreciate it if you could help me figure out what's going on. Please let me know if there's any additional info I can provide.

Thank you in advance!

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?

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()
        }

Pulsator offset during Rotations

Hi,

I changed the layout constraint of the y-Axis in your demo:
screenshot 2016-04-19 14 15 07

Any easy way to fix the position of the Pulsator?
screenshot 2016-04-19 14 15 21

Cheers,
Frederik

dyld: Library not loaded: error

Hi!
I'm using Pulsator with Carthage, and get the following error when I build my app:
dyld: Library not loaded: @rpath/Pulsator.framework/Pulsator
Reason: image not found

Carthage version: 0.11.0
Xcode version: 7.3
Target: 9.3

At compile-time everything is fine.

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?

No such module 'QuartzCore.QuartzCore'

Hi guys, I ran into a problem with Cocoapods, my XCode is 9.1, I only add this lib, pod 'Pulsator', so I open the .xcworkspace generated, but, the Pod scheme didn't build, It throws this error that he can't find the QuartzCore framework.... have u guy already this kind of problem?? Any ideas how to fix it?

screen shot 2017-12-01 at 19 35 30

Missing updateInstanceDelay

I believe that:

open var pulseInterval: TimeInterval = 0

ought to be:

open var pulseInterval: TimeInterval = 0 { didSet { updateInstanceDelay() } }

When starting and then restarting a pulsator, the experience is different on the second and successive runs than the first.
Came across this when setting pulseInterval after setting numPulse and animationDuration

need to pause animation

Thank you for the nice library.

I want to pause animation to show search results count.

Kindly help us.

Not working on Swift 2.3

I ran the pod install, however I couldn't create the Pulsator instance. It seems like the library was not properly load from pod.

Won't compile on Swift 4.2

I'm getting compile issues when trying to compile this on Swift 4.2. I have a fix ready, but can't create a branch on the repo. Can you fix that?

Cocoapods version update.

There is a lot of difference between 0.3.0 tag and master branch.
Would you publish the newest source code to CocoaPods?

Pulse stop working while using in UICollectionviewCell

I want to use pulsator in UICollectionviewCell, the code works fine if I am using in UIViewController, but not working inside cell. or it will start pulsing on other position not under perticular item.

let pulsator = Pulsator()
pulsator.numPulse           = 10
pulsator.radius             = 50
pulsator.animationDuration  = 10
pulsator.backgroundColor    = UIColor(r: 231, g: 22, b: 70).cgColor
imgState.layer.superlayer?.insertSublayer(pulsator, below: imgState.layer)
pulsator.start()

UI Issues

Hi,
I am using your lib. But when I use pulsator on button it effect is not showing on button.Pulsator effect is shown at above left of button and not on button.. I am using auto layout.

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
}`

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?

How to use Pulsator on GoogleMap Marker

When I tried to add it in GoogleMap Marker, its not working...

Here's my code:

var myMarker.position = CLLocationCoordinate2D(latitude: myLatitude , longitude: myLongitude)
myMarker.title = "MyLocation"
myMarker.map = mapView

let pulsator = Pulsator()
pulsator.radius = 240.0
pulsator.backgroundColor = UIColor.blue.cgColor

 myMarker.layer.addSublayer(pulsator)

Theres no error when you compile but the pulsator is not seen only the marker is displayed.

Problems to install "Pulsator" using carthage

Hello everybody, I have a problem tried to install "Pulsator" with carthage you can see the error ... below

Task failed with exit code 65: /usr/bin/xcrun xcodebuild -project /Users/planetmedia/Desktop/notforall/Carthage/Checkouts/Pulsator/Pulsator.xcodeproj -scheme Pulsator -configuration Release -derivedDataPath /Users/planetmedia/Library/Caches/org.carthage.CarthageKit/DerivedData/Pulsator/0.3.0 -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build
I was reading and is because does not support Xcode 8.3.2
What can i do?

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))
    }
}

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()

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.

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 :/

Google Map

I have try many way to add to marker googlemap but unsucessfully.

Performance for plotting thousands of Pulsators

Hello, I am trying to plot thousands of Pulsators on Google Map and the whole view is very slow. Wondering what would be a good practice and if it is possible to plot that many Pulsators on a single page.

Swift 4 migration

Hey,
I think you have already migrated to swift 4 but forgot to update .swift-version file for cocoapods.

Drop support for iOS 8

When installing your library Xcode 12 informs about a warning:

The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99.

The warning is for Pulsator library. I'm installing it via SPM, so no possibility to change it on the fly. With cocoapods people can add post-install script.

Can you bump the minimal target? iOS 8 is a very old system, a tiny percentage, probably not more than 0.5, is still using it.

Swift 2.3

Hey thank you for this great library. I'm having issues implementing pulsator into my swift 2,3 project. I'm using cocoapods and set the version to 0.1.1 but it throws an error saying it can not find QuartzCore.

How do I implement it into my project for swift 2.3?

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?

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?

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()

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?

Animation isn't properly stops.

Hello,

I have faced to an issue. After initializing the Pulsator it doesn't stops animation.

Here some example:
private func setupPulsator() { pulsator.radius = imageButton.bounds.width - 30 pulsator.numPulse = 3 pulsator.position = imageButton.center imageButton.layer.superlayer?.insertSublayer(pulsator, below: imageButton.layer) pulsator.start() }

And then pulsator.stop() doesn't work.

Where is my mistake?

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.