DRPLoadingSpinner is a neat little loading spinner. It's pretty
configurable, so you can achieve a variety of effects. Check out
src/DRPLoadingSpinner.h for all the configurable properties.
Even though it's quite configurable, DRPLoadingSpinner is easy
to get started with. Here's a snippet of creating one with default
DRPLoadingSpinner *spinner = [[DRPLoadingSpinner alloc] init]; [self.view addSubview:spinner]; [spinner startAnimating];
Done! See? That was easy. You can even use DRPLoadingSpinner as a drop-in replacement for UIRefreshControl. Check out its sibling, DRPRefreshControl.
DRPRefreshControl *refreshControl = [[DRPRefreshControl alloc] init]; [refreshControl addToScrollView:self.scrollView target:self action:@selector(refreshTriggered:)];
Bam! Now you've got a snazzy refresh control in just a couple lines of code. Refresh controls can be added to UITableViewControllers and, in iOS 10, any UIScrollView or UIScrollView subclass. You can use either a callback block or a target-action to get notified that a refresh has been triggered.
Swift is not yet source-stable, which means that whenever an update to Swift is released, there is a risk that older Swift code won't compile. You shouldn't have to wait for me or someone else to update this library to a new Swift version in order to use it. The good news is, thanks to Swift-ObjC interop, DRPLoadingSpinner can be accessed easily from Swift code and will not break when new versions are released.
Installing couldn't be easier. Just install the Pod and away you go! If you're not the CocoaPods type, you can always just add the contents of the
src directory to your project and get building!
pod install 'DRPLoadingSpinner'
There are a handful of things you can customize on your loading spinner:
loadingSpinner.colorSequence = @[ UIColor.grayColor ];
loadingSpinner.colorSequence = @[ UIColor.cyanColor, UIColor.magentaColor, UIColor.yellowColor, UIColor.blackColor ];
loadingSpinner.backgroundRailColor = UIColor.lightGrayColor;
loadingSpinner.lineWidth = 3; // a pretty thick line.
M_PIfamily of constants!
loadingSpinner.maximumArcLength = (2 * M_PI) - M_PI_4; // line will get as long as 7/8 the circumference of the circle loadingSpinner.minimumArcLength = 0; // line will completely disappear at its shortest.
loadingSpinner.rotationDirection = DRPRotationDirectionCounterClockwise;
loadingSpinner.rotationCycleDuration = 2; // a short and pretty noticeable rotation
loadingSpinner.drawCycleDuration = 1;
DRPLoadingSpinnerTimingFunctionfor some presets.
loadingSpinner.drawTimingFunction = [DRPLoadingSpinnerTimingFunction sharpInOut];
-stopAnimatingdo exactly what their names suggest.
-isAnimatingwill tell you whether or not the spinner is currently animating. Nifty!
Have something to add? Fork this repo and then submit a pull request. I'm always happy to check them out.