TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jun 2015 |
Maintained by David N.
SKSpinner is an iOS control that displays a loader while tasks is being processed.
SKSpinner works on any iOS version and is compatible with ARC projects. It depends on the following Apple frameworks, which should already be included with most Xcode templates:
Alternatively you can directly add the SKSpinner.h
and SKSpinner.m
source files to your project.
SKSpinner.h
and SKSpinner.m
onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project. #import "SKSpinner.h"
.(see sample Xcode project in /Demo
)
The main guideline you need to follow when dealing with SKSpinner while running long-running tasks is keeping the main thread work-free, so the UI can be updated promptly. The recommended way of using SKSpinner is therefore to set it up on the main thread and then spinning the task, that you want to perform, off onto a new thread.
[SKSpinner showTo:self.view animated:YES];
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
// Do something...
dispatch_async(dispatch_get_main_queue(), ^{
[SKSpinner hideAnimated:NO];
});
});
If you need to configure the spinner you can do this by using the SKSpinner reference that initWithView: returns.
SKSpinner *spinner = [[SKSpinner alloc] initWithView:self.view];
spinner.minShowTime = 5.f;
spinner.color = [UIColor greenColor];
[spinner showAnimated:YES];
[self doSomethingInBackgroundWithProgressCallback:^(float progress) {
// Do something...
} completionCallback:^{
[spinner hideAnimated:YES];
}];
API documentation is provided in the header file (SKSpinner.h).
This code is distributed under the terms and conditions of the MIT license.