AMLoadingSpinner
is a simple way to show animated spinner for displaying the progress of an ongoing task.
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
Drag the AMLoadingSpinner/AMLoadingSpinner
folder into your project.
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).
+(void) setAnimationImages:(NSArray <UIImage *>*)images;
You can pass a single-object array in this method to get static image without animation.
+(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.
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:
+(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)
To show/hide spinner, use these methods:
+(void) show;
+(void) showWithProgress:(CGFloat)progress;
+(void) dismiss;
+(void) dismissWithDelay:(NSTimeInterval)delay;
Note, that user interaction with app is disabled while spinner is showing.
AMLoadingSpinner
is distributed under the terms and conditions of the MIT license.
AMLoadingSpinner
is developed by Artem Mihaylov.
If you're using AMLoadingSpinner
in your project, attribution would be very appreciated.