Giter Site home page Giter Site logo

ninjaprox / nvactivityindicatorview Goto Github PK

View Code? Open in Web Editor NEW
10.6K 204.0 1.1K 6.08 MB

A collection of awesome loading animations

License: MIT License

Swift 99.27% Ruby 0.56% Shell 0.11% C 0.05%
swift animation ios ios-ui ios-animation ios-swift ios-thirdparty ios-lib carthage cocoapods

nvactivityindicatorview's Introduction

NVActivityIndicatorView

Build Status Cocoapods Compatible Carthage Compatible

โš ๏ธ Check out LoaderUI (ready to use with Swift Package Mananger supported) for SwiftUI implementation of this. ๐ŸŽ‰

Introduction

NVActivityIndicatorView is a collection of awesome loading animations.

Demo

Animation types

Type Type Type Type
1. ballPulse 2. ballGridPulse 3. ballClipRotate 4. squareSpin
5. ballClipRotatePulse 6. ballClipRotateMultiple 7. ballPulseRise 8. ballRotate
9. cubeTransition 10. ballZigZag 11. ballZigZagDeflect 12. ballTrianglePath
13. ballScale 14. lineScale 15. lineScaleParty 16. ballScaleMultiple
17. ballPulseSync 18. ballBeat 19. lineScalePulseOut 20. lineScalePulseOutRapid
21. ballScaleRipple 22. ballScaleRippleMultiple 23. ballSpinFadeLoader 24. lineSpinFadeLoader
25. triangleSkewSpin 26. pacman 27. ballGridBeat 28. semiCircleSpin
29. ballRotateChase 30. orbit 31. audioEqualizer 32. circleStrokeSpin

Installation

Cocoapods

Cocoapods is a dependency manager for Swift and Objective-C Cocoa projects. To use NVActivityIndicatorView with CocoaPods, add it in your Podfile.

pod 'NVActivityIndicatorView'

Carthage

Carthage is intended to be the simplest way to add frameworks to your Cocoa application. To use NVActivityIndicatorView with Carthage, add it in your Cartfile.

github "ninjaprox/NVActivityIndicatorView"

Swift Package Manager

The Swift Package Manager is a tool for managing the distribution of Swift code. To use NVActivityIndicatorView with Swift Package Manger, add it to dependencies in your Package.swift

dependencies: [
    .package(url: "https://github.com/ninjaprox/NVActivityIndicatorView.git")
]

Migration

Version 5.0.0 comes with breaking changes. Please refer to the release note for details.

Usage

Firstly, import NVActivityIndicatorView.

import NVActivityIndicatorView

Initialization

Then, there are two ways you can create NVActivityIndicatorView:

  • By storyboard, changing class of any UIView to NVActivityIndicatorView.

Note: Set Module to NVActivityIndicatorView.

NVActivityIndicatorView(frame: frame, type: type, color: color, padding: padding)

Control

Start animating.

activityIndicatorView.startAnimating()

Stop animating.

activityIndicatorView.stopAnimating()

Determine if it is animating.

animating = activityIndicatorView.isAnimating

Change properties

In storyboard, you can change all properties in Attributes inspector tab of Utilities panel.

Note: Use one of values (case-insensitive) in Animation types for Type Name.

All properties are public so you can change them after initializing.

Note: All changes must be made before calling startAnimating().

Documentation

https://nvactivityindicatorview.vinhis.me/

Acknowledgment

Thanks Connor Atherton for inspired Loaders.css and Danil Gontovnik for DGActivityIndicatorView.

License

The MIT License (MIT)

Copyright (c) 2016 Vinh Nguyen @ninjaprox

nvactivityindicatorview's People

Contributors

131e55 avatar basememara avatar buguibu avatar coybit avatar csigritz avatar deepankvora avatar gregttn avatar iaugux avatar jobinsjohn avatar jp26jp avatar kocmohabta avatar kwongius avatar loicgriffie avatar marvinnazari avatar matibzurovski avatar mnatsakanov avatar morizotter avatar mplorentz avatar msavisko avatar ninjaprox avatar ozgur avatar quantum2 avatar rlester avatar salbertson avatar samjohn avatar siarheiyurcha avatar spriter avatar tako3 avatar vinzius avatar winkelsdorf 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  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

nvactivityindicatorview's Issues

How To Add Text ?

First Of All , let me start by saying it's a great project !
I've tried to edit it and add Text to the Indicator, but without success.
Is it possible ?

Carthage update fails

I get following error when trying to use this via carthage.

Xcode version is 8.0 GM Seed. (8A218a)

  • Cartfile

github "ninjaprox/NVActivityIndicatorView"

  • Error Log
*** Fetching NVActivityIndicatorView
*** Checking out NVActivityIndicatorView at "v2.12"
*** xcodebuild output can be found in /var/folders/b9/l5wkgvmx15vdcfpj31jz4wyw0000gn/T/carthage-xcodebuild.lflaIg.log
*** Building scheme "NVActivityIndicatorView" in NVActivityIndicatorViewDemo.xcodeproj
** CLEAN FAILED **


The following build commands failed:
    Check dependencies
(1 failure)
** BUILD FAILED **


The following build commands failed:
    Check dependencies
(1 failure)
A shell task (/usr/bin/xcrun xcodebuild -project /Volumes/Data/Work/My Project/Carthage/Checkouts/NVActivityIndicatorView/NVActivityIndicatorViewDemo.xcodeproj -scheme NVActivityIndicatorView -configuration Release -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build) failed with exit code 65:
** CLEAN FAILED **


The following build commands failed:
    Check dependencies
(1 failure)
** BUILD FAILED **


The following build commands failed:
    Check dependencies
(1 failure)

Why pacman as the default?

Sure, pacman is awesome, childhood stuff and all.
But, for a production-ready application, who would use that?

Just a thought

indicator is relative too big

Only one line of code is used in my project:

self.startActivityAnimating("Loading...",type: .LineScalePulseOut,color: UIColor.whiteColor(),padding: 0)

However, it seems it's bigger than demo

image

Change Size handling, add IBDesignable support

Ninja,

as a feature suggestion: Please add support for IBInspectable and IBDesignable.
See http://nshipster.com/ibinspectable-ibdesignable/ for details.

This would allow Users settings properties (Type, Color) in Interface Builder.

Looks like your Init?(coder) is also broken, if I set a specific size in IB it is not applied during runtime and defaults to NVActivityIndicatorView.DEFAULT_SIZE. Use case: Tried to use AutoLayout to resize the NVActivityIndicatorView depending on Size Class.

Edit: Before someone suggest, I am aware of User defined runtime attributes. But IBDesignable is a huge gain compared to that ;)

Edit2: Why are you using a Size property at all? Any reason I don't see right now? You have the frame.size of NVActivityIndicatorView which is a subclass of UIView. That's enough imo for both Init(coder) and Init(frame,..).

Cheers,
Frederik

How To Add footer list ?

I appreciated your project.I want to add footer list. my problem is that this view cover all the page width and It do not accept the size that I put for it.

Stop Animation doesn't work when viewControllers are presenting/dismissing

Steps to reproduce:
Have a tableView in a viewController, add the loading, go to another viewController, do something network-related, add another loading, stop the loading animation after you receive a response, call a delegate method back and dismiss the current viewController, stop the animation in the delegate method, nothing happens.

I dug into the code and changed the following inside hide() method inside NVActivityIndicatorPresenter.swift from

for item in UIApplication.shared.keyWindow!.subviews
    where item.restorationIdentifier == restorationIdentifier {
        item.removeFromSuperview()
}

to

for window in UIApplication.shared.windows {
    for item in window.subviews
        where item.restorationIdentifier == restorationIdentifier {
            item.removeFromSuperview()
        }
}

and it works. Is there any reason why keyWindow is used instead of windows?

Issue with DEFAULT_PADDING

Hi there,

today I stumbled about an glitch with the latest changes we made: The animations were cut off.

I checked the changes we made and found that the animationRect in setUpAnimation() has had a negative value for width and height.

The reason: You set a DEFAULT_PADDING of 25 instead of 0 what I proposed in my PR some weeks ago. My animation setup currently is only 25x25, thus the negative value.

Short question: Why default to 25? I think it's better to stick to 0 and leave it up to the user to adjust that default via Code or IB.

Cheers,
Frederik

Switching from portrait to landscape and vice versa

Hi,

when I switch from portrait to landscape mode the animation is not in the center anymore where it used to be before. The containing view rotates appropriately but the animation just stays where it used to stay before.

Cheers,

Frank

How to pause animation

Hi,
I have used Pulse animation in my app but I want to pause it.

I want to pause all bars as the each bar have it's position as it is.

Is there any feature available for this?

Thank you,

How to check animation is starting?

Hi everybody
I can't find any method/property for check animating start in view? (like isAnimating)
for example start animating in viewWillAppear function and i want when tableview is reloading and finish work in didEndDisplaying func; stop animating...
Thank's

Setting user defined inspectables in interface builder causes crash.

Hi,

when creating an instance in interface builder, and setting the inspected properties available, I get this error in the console when running an app that I am building: Failed to set (color) user defined inspected property on (UIView): [<UIView 0x7b63ba40> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key color. 2016-10-13 16:41:27.470 .

How to add this in an object file rather than using it in view controllers

Hello,

First of all great work. I just made a wrapper for webservice calling using alamofire. I need to insert your library in that wrapper but since you used it for uiviewcontroller only it is quite not achievable by me. Can you help me out.

class func serviceCall(urlEnum: URLRequestConvertible, vC: UIViewController, success: (JSON) -> Void, failure: (NSError) -> Void) {
    let size = CGSize(width: 30, height: 30)
    vC.startActivityAnimating(size, message: "Loading...", type: NVActivityIndicatorType(rawValue: 9)!)

    Alamofire.request(urlEnum).responseJSON {
        (responseObject) -> Void in

            print(responseObject)

        if responseObject.result.isSuccess {
            let resJson = JSON(responseObject.result.value!)
            success(resJson)
        }
        if responseObject.result.isFailure {
            let error: NSError = responseObject.result.error!
                failure(error)
        }
    }
}

Above is my a function in my wrapper class.

Aligning problem on XCode 8

I'm having trouble to align the indicator view on storyboard. I have a basic app and single view controller. Indicator is located to the center of view and it spins until the page contents load from the server. However, when I hit the run button, loading indicator is spinning in the right corner of the view, overflowing and not aligning to the center itself.

Scenario can be replicated by following steps:

  • Add a UIView to a UIViewController on storyboard.
  • Add static height and width and contraints (let say 100,100)
  • Align center vertically and horizontally
  • Change the class of UIView to NVActivityIndicatorView
  • Assign activity type and color.
  • Hit the run button.

I'm building with XCode 8 and Swift 3.0. Is there any way to fix this?

Thanks in advance.

carthage support error

Hello! I add your library with carthage, but now my project not archived with reason:

ld: bitcode bundle could not be generated because '/Users/tygeddar/mobile_aplication/Pintv/Carthage/Build/iOS/NVActivityIndicatorView.framework/NVActivityIndicatorView' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build for architecture armv7

Xcode8 swift3 problem

i'm using:
Xcode8
swift: 3
cocoapods:1.1.0 rc2
NVActivityIndicatorView: 3.0
iPhone7 simulator

i have other frameworks in pod files, but only NVActivityIndicatorView has following errors when trying to build in Xcode

Undefined symbols for architecture x86_64:
"(extension in NVActivityIndicatorView):NVActivityIndicatorView.NVActivityIndicatorViewable.stopAnimating () -> ()", referenced from:
Test.MainViewController.((fetchData in _429C5DB4CBE3D572A146F1757B8C8AAF) () -> ()).(closure #2).(closure #1).(closure #1) in MainViewController.o
"(extension in

hi~I got a problem with it,when I use MBProgressHUD for its customView

when I use NVActivityIndicatorView as the customView,its frame can't changed,just look like this,I want the activityIndicatorView move to the center of the HUD.,What's the problem?Please help me !!thx a lot!
qq20160906-1

the code:

let hud = MBProgressHUD.showHUDAddedTo(view, animated: true)
hud.mode = .CustomView
let activityIndicatorView = NVActivityIndicatorView(frame: CGRectMake(0, 0, 50, 50), type: NVActivityIndicatorType.LineScale)
activityIndicatorView.startAnimation()
hud.customView = activityIndicatorView
hud.square = true
hud.label.text = "test words..."
hud.hideAnimated(true, afterDelay: delayTime)

NVActivityIndicatorView added with storyboard sometimes ignore contraints

I have noticed that if I add the NVActivityIndicatorView with storyboard it sometimes ignores the contraint I set in storyboard. I dont get any error/warnings but a 55x55 loader ended up being 1000x1000 in size and stuck to the bottom left corner.

I think this happens when you have alot of UI going on in your VC added with storyboard - I dont see this happen when added with code or in light VC's

[!] Unable to satisfy the following requirements

I keep getting the error message on trying to install the pod: [!] Unable to satisfy the following requirements: - NVActivityIndicatorView required by Podfile

This is how my Podfile looks like:
target 'MyTarget' do
pod "AFNetworking"
pod "NVActivityIndicatorView"
end

What am I missing?

View is hidden by the stopAnimation method?

@ninjaprox
// this is my test code

self.activityIndicatorView.startAnimation()
self.activityIndicatorView.hidesWhenStopped = false

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(NSEC_PER_SEC * 3)), dispatch_get_main_queue()) {
    self.activityIndicatorView.stopAnimation()
}

Even if I wrote self.activityIndicatorView.hidesWhenStopped = false, The view is still hidden?

Using from ObjC ?

Hi there,

I'm using your controller in a swift project, and it's so awesome that I want to use it in another one, an ObjC one. From what I understand I only need to import the framework and I'll be set to go. (doc)

But for some reason I can't set the type of the view. Ok, fine, I'll use the default one. But when trying to go ahead, I find out I can't even init the view. I tried both [[NVActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)]; and [[NVActivityIndicatorView alloc] init]; to no avail.

Is there something else I should be doing? Thanks in advance!

Dragged files into project, can't figure out how to use them

class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

    @IBOutlet weak var imageView: UIImageView!
    let imagePicker = UIImagePickerController()
    @IBOutlet var spinner: UIActivityIndicatorView!
    @IBOutlet weak var textResults: UITextView!
    @IBOutlet weak var wordCount: UILabel!
    @IBOutlet weak var textFoundLabel: UILabel!
    @IBOutlet var activityIndicator: NVActivityIndicatorView! //Use of undeclared type 'NVActivityIndicatorView'

I started by making a UIView in storyboard and changing its class to 'NVActivityIndicator' in the file inspector. Then I control-dragged it to my ViewController.swift as an IBOutlet and the code will not compile. I tried to add 'NVActivityIndicator' to the class but end up with 'no such module' error.

The 'NVActivityIndicatorView' folder is copied into my Xcode project, I'm not using pods.

I might be doing this completely wrong, I'm new to this โ€“ any help would be appreciated.
(using Xcode 8 GM)

Swift 3.0 compiler error

I have got this error after pulling mater branch with pod file.
I have used pod 'NVActivityIndicatorView' and got this compiler error.

'shared' is unavailable: Use view controller based solutions where appropriate instead.

I got this errors on NVActivityIndicatorPresenter line 149, 153 in show / hide methods.

Long compile time in Pacman

Hello. Compiling of NVActivityIndicatorAnimationPacman.swift takes a lot of time

3633.1ms /Pods/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationPacman.swift:61:10    func circleInLayer(_ layer: CALayer, size: CGSize, color: UIColor)

3615.6ms    /Pods/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationPacman.swift:18:10 func pacmanInLayer(_ layer: CALayer, size: CGSize, color: UIColor)

3515.1ms    /Pods/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationPacman.swift:18:10 func pacmanInLayer(_ layer: CALayer, size: CGSize, color: UIColor)

3331.8ms    /Pods/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationPacman.swift:61:10 func circleInLayer(_ layer: CALayer, size: CGSize, color: UIColor)

for example another animation only 130ms

130.8ms /Pods/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationOrbit.swift:29:10 func ring1InLayer(_ layer: CALayer, size: CGSize, color: UIColor)

pod try project sigabrt

dyld: Library not loaded: @rpath/NVActivityIndicatorView.framework/NVActivityIndicatorView
Referenced from: /var/containers/Bundle/Application/3CD7E242-1093-4469-8A48-6EA1505B5307/NVActivityIndicatorViewDemo.app/NVActivityIndicatorViewDemo
Reason: image not found

Add delays to start and stop

Hi! It would be awesome to have support for use cases where:

  1. If the time difference between the startActivityAnimating and stopActivityAnimating calls is below certain threshold (e.g 200 ms), then do not display the corresponding NVActivityIndicatorView instance.
  2. Once the NVActivityIndicatorView is shown, have it stay visible for a minimum amount of time in order to avoid fast flashes showing and hiding.

As a user, I would like to configure those time thresholds as a general setting, but also have the option to override those in particular calls. For instance, if I know that certain network call will last a considerable amount of time, then I would like to show the loading view instantly.

I could try adding it and then submit a pull request. What do you think?

Extraneous argument label 'size:' in call

Hello,

I have updated my project to Swift version 3 and NVActivityIndicatorView 9 issues

image

It seems that the "size:" label is now useless. Any idea?

Edit: I have 15 issues

Vincent

Animation appears at (0,0) of frame

So this is how I set up the activity indicator:

let loading = NVActivityIndicatorView(frame: CGRectZero, type: .BallPulse, color: .whiteColor())
loading.translatesAutoresizingMaskIntoConstraints = false
signInButton.addSubview(loading)
loading.snp_makeConstraints{(make) -> Void in
    make.center.width.height.equalTo(signInButton)
}
loading.backgroundColor = UIColor.blueColor() // this is to see where the frame is.
loading.startAnimation()

But in the simulator it looks like this:

screen shot 2016-04-08 at 11 51 45 am

Can't access methods.

Hello! I just pod installed and can't get access to anything from NVActivityIndicatorView except for NVActivityIndicatorViewVersionNumber. Any ideas?

Swift 2.0

Any luck that this library is available in Swift 2.0?

Pod seems to be broken

Hi,
I got an error while running the pod install:

Installing NVActivityIndicatorView (1.0)

[!] Error installing NVActivityIndicatorView
[!] /usr/bin/git clone https://github.com/ninjaprox/NVActivityIndicatorView.git /var/folders/x6/j9_t239j1pgbcmnjz3nsps3w0000gn/T/d20150730-9266-d4321u --single-branch --depth 1 --branch v1.0

Cloning into '/var/folders/x6/j9_t239j1pgbcmnjz3nsps3w0000gn/T/d20150730-9266-d4321u'...
warning: Could not find remote branch v1.0 to clone.
fatal: Remote branch v1.0 not found in upstream origin

Orientation Support

Can u please advise me how to handle orientation of the NvActivityIndicatorView. For now the view is displaced when i switch to landscape mode.
@ninjaprox
Thanks in advance.

Infinite loop

    /**
     Stop animating.
     */
    @available(*, deprecated=2.11, renamed="stopAnimating()")
    public func stopAnimation() {
        self.stopAnimation()
    }

It should be changed to -> self. stopAnimating()

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.