Giter Club home page Giter Club logo

monactivityindicatorview's Introduction

MONActivityIndicatorView

MONActivityIndicatorView is an awesome custom activity indicator view for iOS.

![MONActivityIndicatorView] (https://raw.github.com/mownier/MONActivityIndicatorView/master/MONActivityIndicatorView-Screenshot.gif)

Installation

Manual Install

  • Copy and add the files MONActivityIndicatorView.h and MONActivityIndicatorView.m to your project.
  • Add the QuartzCore framework to your project.
  • Then do, import MONActivityIndicatorView.h

From CocoaPods

  • Add pod 'MONActivityIndicatorView' to your Podfile.
  • Then pod install in the terminal.

Usage

Initialization

- (void)viewDidLoad {
  [super viewDidLoad];

  MONActivityIndicatorView *indicatorView = [[MONActivityIndicatorView alloc] init];
  [self.view addSubview:indicatorView];
}

Toggling Indicator

[indicatorView startAnimating];
[indicatorView stopAnimating];

Customization

Default Property Values

  • Animation delay : delay = 0.2
  • Animation duration : duration = 0.8
  • Number of circles : numberOfCircles = 5
  • Circle's radius : radius = 10
  • Circle's internal spacing : internalSpacing = 5
  • Circle's background Color : defaultColor = [UIColor lightGrayColor]

Custom Property Values

- (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.center = self.view.center;
  [self.view addSubview:indicatorView];
  [indicatorView startAnimating];
}

Custom Circle's Background Color

First, assign the MONActivityIndicatorViewDelegate protocol to a view controller. Then, implement the method activityIndicatorView:circleBackgroundColorAtIndex:

@interface ViewController : UIViewController <MONActivityIndicatorViewDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  
  MONActivityIndicatorView *indicatorView = [[MONActivityIndicatorView alloc] init];
  indicatorView.delegate = self;
  indicatorView.numberOfCircles = 3;
  indicatorView.radius = 20;
  indicatorView.internalSpacing = 3;
  indicatorView.duration = 0.5;
  indicatorView.delay = 0.5
  indicatorView.center = self.view.center;
  [self.view addSubview:indicatorView];
  [indicatorView startAnimating];
}

- (UIColor *)activityIndicatorView:(MONActivityIndicatorView *)activityIndicatorView
      circleBackgroundColorAtIndex:(NSUInteger)index {
  // For a random background color for a particular circle
  CGFloat red   = (arc4random() % 256)/255.0;
  CGFloat green = (arc4random() % 256)/255.0;
  CGFloat blue  = (arc4random() % 256)/255.0;
  CGFloat alpha = 1.0f;
  return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
}

@end

monactivityindicatorview's People

Contributors

aryt avatar gmarcus avatar mownier avatar ssimonov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.