GithubHelp home page GithubHelp logo

bfeher / bfradialwaveview Goto Github PK

View Code? Open in Web Editor NEW
91.0 7.0 7.0 12.94 MB

A mesmerizing view with lots of options. It is meant to be used with BFRadialWaveHUD, but you are free to take it :)

License: MIT License

Objective-C 98.84% Ruby 1.16%

bfradialwaveview's Introduction

BFRadialWaveView

CocoaPods

A mesmerizing view with lots of options. It is meant to be used with BFRadialWaveHUD, but you are free to take it :)


Click the screenshot below for an animated gifv!
Animated Screenshot

About

BFRadialWaveView is a sublcass of UIView. It displays a radial wave with various options. It was made to be the progress/spinner view for BFRadialWaveHUD.

Changes

Please refer to this CHANGELOG.md.

To do:

  • Restart animations on app wake-up.
  • Move resources into a resource directory, reflecting this change in the cocoapod. (Fix file structure)

Modes

BFRadialWaveViewMode_Default       // Default: A swirly looking thing.
BFRadialWaveViewMode_KuneKune      // Kune Kune: A creepy feeler looking thing.
BFRadialWaveViewMode_North         // North: Points upwards.
BFRadialWaveViewMode_NorthEast     // North East: Points upwards to the right.
BFRadialWaveViewMode_East          // East: Points right.
BFRadialWaveViewMode_SouthEast     // South East: Points downwards to the right.
BFRadialWaveViewMode_South         // South: Points down.
BFRadialWaveViewMode_SouthWest     // South West: Points downwards to the left.
BFRadialWaveViewMode_West          // West: Points left.
BFRadialWaveViewMode_NorthWest     // North West: Points at Kanye.

Methods

Initializer

Use this when you make a BFRadialWaveView in code.

/**
 *  Custom initializer. Use this when you make a BFRadialWaveView in code.
 *
 *  @param container       A UIView to place this one in.
 *  @param numberOfCircles NSInteger number of circles. Min = 3, Max = 20.
 *  @param circleColor     UIColor to set the circles' strokeColor to.
 *  @param mode            BFRadialWaveViewMode.
 *  @param strokeWidth     CGFloat stroke width of the circles.
 *  @param withGradient    BOOL flag to decide whether or not to draw a gradient in the background.
 *
 *  @return Returns A BFRadialWaveView! Aww yiss!
 */
- (instancetype)initWithView:(UIView *)container
                     circles:(NSInteger)numberOfCircles
                       color:(UIColor *)circleColor
                        mode:(BFRadialWaveViewMode)mode
                 strokeWidth:(CGFloat)strokeWidth
                withGradient:(BOOL)withGradient;

Setup

Use this when you made a BFRadialWaveView in the storyboard or xib

/**
 *  Setup. Use this when you made a BFRadialWaveView in the storyboard or xib.
 *
 *  @param container       A UIView to place this one in.
 *  @param numberOfCircles NSInteger number of circles. Min = 3, Max = 20.
 *  @param circleColor     UIColor to set the circles' strokeColor to.
 *  @param mode            BFRadialWaveViewMode.
 *  @param strokeWidth     CGFloat stroke width of the circles.
 *  @param withGradient    BOOL flag to decide whether or not to draw a gradient in the background.
 */
- (void)setupWithView:(UIView *)container
              circles:(NSInteger)numberOfCircles
                color:(UIColor *)circleColor
                 mode:(BFRadialWaveViewMode)mode
          strokeWidth:(CGFloat)strokeWidth
         withGradient:(BOOL)withGradient;

Loading

/** Show a basic view with no progress. */
- (void)show;

Progress

/**
 *  Show a view with progress.
 *
 *  @param progress CGFloat between 0.f and 1.f. The progress to show.
 */
- (void)showProgress:(CGFloat)progress;

Success

/** Show a success view. */
- (void)showSuccess;

Error

/** Show an error view. */
- (void)showError;

Update

/**
 *  Update the progress to a certain value.
 *
 *  @param progress CGFloat between 0.f and 1.f. The progress to show.
 */
- (void)updateProgress:(CGFloat)progress;
/**
 *  Update the circle color on the fly.
 *
 *  @param color UIColor to set the circles' strokeColor to.
 */
- (void)updateCircleColor:(UIColor *)color;

Pause and Resume

Pause and Resume features graciously added by GitHub user @fco-edno :)

/** Pause the animation. */
- (void)pauseAnimation;

/** Resume the animation. */
- (void)resumeAnimation;

/**
 *  Check the paused/not-paused state of the view's animations.
 *
 *  @return Returns a BOOL flag indicating the state of the animation being either paused (YES) or not-paused (NO).
 */
- (BOOL)isPaused;

Fun

/**
 *  Activate of Deactivate disco mode! This will rapidly cycle colors through your BFRadialWaveView. Without setting the colors explicitly, a rainbow is used.
 *
 *  @param on BOOL flag to turn disco mode on (YES) or off (NO).
 */
- (void)disco:(BOOL)on;

Properties

/** The diameter of the view (including progress circle). */
@property (nonatomic, readonly) CGFloat diameter;

/** The UIColor to set the progress circle to. Default is the same as the circleColor passed into the initializer or the setup. */
@property (nonatomic) UIColor *progressCircleColor;

/** The UIColor to set the success checkmark to. By default it is the same as the circleColor passed into the initializer or the setup. */
@property (nonatomic) UIColor *checkmarkColor;

/** The UIColor to set the failure cross to. By default it is the same as the circleColor passed into the initializer or the setup. */
@property (nonatomic) UIColor *crossColor;

/** An NSArray of colors to use for disco mode. By default it is the rainbow. */
@property (nonatomic) NSArray *discoColors;

/** CGFloat speed for the disco animation. Default is 0.33f. */
@property (nonatomic) CGFloat discoSpeed;

/** BFRadialWaveViewDelegate delegate for our protocol. */
@property id <BFRadialWaveViewDelegate> delegate;

Usage

Be sure the check out the included demo app to see examples on how to use BFRadialWaveView.

Add the BFRadialWaveView header and implementation files to your project. (BFRadialWaveView.h & BFRadialWaveView.m) as well as the BFGradientCALayer header and implementation files to your project. (BFGradientLayer.h & BFGradientLayer.m)

Working Example

BFRadialWaveView *radialWaveView;
radialWaveView = [[BFRadialWaveView alloc] initWithView:self.view
                                                circles:BFRadialWaveView_DefaultNumberOfCircles
                                                  color:nil
                                                   mode:BFRadialWaveViewMode_Default
                                            strokeWidth:BFRadialWaveView_DefaultStrokeWidth
                                           withGradient:YES];
[radialWaveView show];

Customized Example

BFRadialWaveView *radialWaveView;
radialWaveView = [[BFRadialWaveView alloc] initWithView:self.view
                                                circles:10
                                                  color:[UIColor darkGray]
                                                   mode:BFRadialWaveViewMode_North
                                            strokeWidth:5.f
                                           withGradient:NO];
[radialWaveView disco:YES];   // Disco time!
[radialWaveView showProgress:someProgressBetweenZeroAndOne];

CocoaPods

CocoaPods are the best way to manage library dependencies in Objective-C projects. Learn more at http://cocoapods.org

Add this to your podfile to add BFRadialWaveView to your project.

platform :ios, '7.1'
pod 'BFRadialWaveView'

License

BFRadialWaveView uses the MIT License:

Please see included LICENSE file.

bfradialwaveview's People

Contributors

bfeher avatar readmecritic avatar xico42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

bfradialwaveview's Issues

How to stop the animation?

I notice that when i leave the screen, and then comeback, the radialView is stopped. That's why in
the examples in the view: willAppear lifecycle method it is used [radialView show];

But i would like to stop the animation at a certain point. How could i achieve it?

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.