MONActivityIndicatorView is an awesome custom activity indicator view for iOS.
![MONActivityIndicatorView] (https://raw.github.com/mownier/MONActivityIndicatorView/master/MONActivityIndicatorView-Screenshot.gif)
- Copy and add the files
MONActivityIndicatorView.h
andMONActivityIndicatorView.m
to your project. - Add the QuartzCore framework to your project.
- Then do,
import MONActivityIndicatorView.h
- Add
pod 'MONActivityIndicatorView'
to your Podfile. - Then
pod install
in the terminal.
- (void)viewDidLoad {
[super viewDidLoad];
MONActivityIndicatorView *indicatorView = [[MONActivityIndicatorView alloc] init];
[self.view addSubview:indicatorView];
}
[indicatorView startAnimating];
[indicatorView stopAnimating];
MONActivityIndicator is totally customizable:
- (void)viewDidLoad {
[super viewDidLoad];
MONActivityIndicatorView *indicatorView = [[MONActivityIndicatorView alloc] init];
indicatorView.numberOfCircles = 3;
indicatorView.radius = 20;
indicatorView.internalSpacing = 3;
indicatorView.duration = 0.5;
indicatorView.delay = 0.5
...
[indicatorView startAnimating];
}
There are several ways to set the color of the dots in this component.
Option 1
MONActivityIndicatorView conforms to UIAppearance, so you can do this:
[[MONActivityIndicatorView appearance] setTintColor:[UIColor redColor]];
or this:
MONActivityIndicatorView *indicatorView = [[MONActivityIndicatorView alloc] init];
indicatorView.tintColor = [UIColor redColor];
Option 2
MONActivityIndicatorView supports IBInspectable, so you can set the tintColor in Interface Builder/Storyboard.
Option 3
MONActivityIndicatorViewDelegate provides the method activityIndicatorView:dotColorAtIndex:
, which you can implement in your delegate.
@interface ViewController : UIViewController <MONActivityIndicatorViewDelegate>
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
MONActivityIndicatorView *indicatorView = [[MONActivityIndicatorView alloc] init];
indicatorView.delegate = self;
...
[indicatorView startAnimating];
}
- (UIColor *)activityIndicatorView:(MONActivityIndicatorView *)activityIndicatorView dotColorAtIndex:(NSUInteger)index {
return [UIColor redColor];
}
@end