Skip to content

A simple way to show animated spinner for displaying the progress of an ongoing task

License

Notifications You must be signed in to change notification settings

MihaylovArtem/AMLoadingSpinner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AMLoadingSpinner

Pod Version Platforms License

AMLoadingSpinner is a simple way to show animated spinner for displaying the progress of an ongoing task.

Getting started

From CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like AMLoadingSpinner in your projects. First, add the following line to your Podfile:

pod 'AMLoadingSpinner'

Second, install AMLoadingSpinner into your project:

pod install

Manually

Drag the AMLoadingSpinner/AMLoadingSpinner folder into your project.

Usage

AMLoadingSpinner is a singleton, which will always be shown as full-screen subview of application's key window. This spinner has no default animations, so to use it you need to have an image sequence of your animation (array of images).

Customization

Foreground

Required
+(void) setAnimationImages:(NSArray <UIImage *>*)images;

You can pass a single-object array in this method to get static image without animation.

Optional
+(void) setAnimationDuration:(NSTimeInterval)duration;   // Default is 5.0 seconds
+(void)setForegroundImageViewSize:(CGSize)size;          // Default is (100, 100)

Note that spinner will always be shown in the middle of the screen.

Background

You can choose the type of spinner's background view. Type of background is enum AMLoadingSpinnerBackgroundType and it have 4 values:

AMLoadingSpinnerBackgroundTypeFullScreen    // Full-screen background view                   
AMLoadingSpinnerBackgroundTypeClear         // Background view is not shown
AMLoadingSpinnerBackgroundTypeDefaultView   // Background view is rectangle or square
AMLoadingSpinnerBackgroundTypeCustomView    // Custom background view

You can customize background view with these methods:

Optional
+(void) setBackgroundType:(AMLoadingSpinnerBackgroundType)type;   // Default is AMLoadingSpinnerBackgroundTypeClear

//Works ONLY when for AMLoadingSpinnerBackgroundTypeCustomView type
+(void) setBackgroundView:(UIView *)view;

//Works ONLY when for AMLoadingSpinnerBackgroundTypeDefaultView type
+(void) setBackgroundViewSize:(CGSize)size;               // Default is (200, 200)
+(void) setBackgroundViewCornerRadius:(CGFloat)radius;    // Default is 10.0

//Works ONLY when for AMLoadingSpinnerBackgroundTypeDefaultView and AMLoadingSpinnerBackgroundTypeFullScreen types
+(void) setBackgroundViewColor:(UIColor *)color;       // Default is (255, 255, 255, 0.7)

Actions

To show/hide spinner, use these methods:

Showing

+(void) show;                                
+(void) showWithProgress:(CGFloat)progress;

Dismissing

+(void) dismiss;                                  
+(void) dismissWithDelay:(NSTimeInterval)delay;

Note, that user interaction with app is disabled while spinner is showing.

License

AMLoadingSpinner is distributed under the terms and conditions of the MIT license.

Credits

AMLoadingSpinner is developed by Artem Mihaylov. If you're using AMLoadingSpinner in your project, attribution would be very appreciated.