GithubHelp home page GithubHelp logo

brianhacks / asprogresspopupview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alskipp/asprogresspopupview

0.0 2.0 0.0 1.89 MB

A progress view showing percentage complete in a popup view

License: MIT License

Ruby 3.00% Objective-C 97.00%

asprogresspopupview's Introduction

ASProgressPopUpView

###What is it?

A UIProgressView subclass that displays the percentage complete in an easy to customize popUpView.

![screenshot] (http://alskipp.github.io/ASProgressPopUpView/img/screenshot1.gif)

If you'd like similar functionality for UISlider, then take a look at ASValueTrackingSlider.

Features

  • Live updating of progress
  • Customizable properties:
    • textColor
    • font
    • popUpViewColor
    • popUpViewAnimatedColors - popUpView and progress bar color animate as value changes
    • popUpViewCornerRadius
  • Optional dataSource - supply your own custom text to the popUpView label
  • Wholesome springy animation

Which files are needed?

For CocoaPods users, simply add pod 'ASProgressPopUpView' to your podfile. Don't forget, CocoaPods includes the try command, type $ pod try ASProgressPopUpView in the terminal, CocoaPods will download the demo project into a temp folder and open it in Xcode. Magic.

If you don't use CocoaPods, just include these files in your project:

  • ASProgressPopUpView (.h .m)
  • ASPopUpView (.h .m)

How to use it

It’s very simple. Drag a UIProgressView into your Storyboard/nib and set its class to ASProgressPopUpView – that's it. The example below demonstrates how to customize the appearance.

self.progressView.font = [UIFont fontWithName:@"Futura-CondensedExtraBold" size:26];
self.progressView.popUpViewAnimatedColors = @[[UIColor redColor], [UIColor orangeColor], [UIColor greenColor]];
self.progressView.popUpViewCornerRadius = 16.0;

To show the popUpView, just call:

[self.progressView showPopUpViewAnimated:YES];

And to hide:

[self.progressView hidePopUpViewAnimated:YES];

You update the value exactly as you would normally use a UIProgressView, just update the progress property self.progressView.progress = 0.31;.

![screenshot] (http://alskipp.github.io/ASProgressPopUpView/img/screenshot2.png)

With version 0.7.1 and above, the animated progress method is supported - (void)setProgress:(float)progress animated:(BOOL)animated. When updating the progress in increments > 0.05 the results will be much smoother using the animated form.

###How to use custom strings in popUpView label

Set your controller as the dataSource to ASProgressPopUpView, then return NSStrings for any progress values you want to customize.

- (NSString *)progressView:(ASProgressPopUpView *)progressView stringForProgress:(float)progress
{
    NSString *s;
    if (progress < 0.2) {
        s = @"Just starting";
    } else if (progress > 0.4 && progress < 0.6) {
        s = @"About halfway";
    } else if (progress > 0.75 && progress < 1.0) {
        s = @"Nearly there";
    } else if (progress >= 1.0) {
        s = @"Complete";
    }
    return s;
}

![screenshot] (http://alskipp.github.io/ASProgressPopUpView/img/screenshot3.png)

###How to use with UITableView

To use effectively inside a UITableView you need to implement the <ASProgressPopUpViewDelegate> protocol. If you just embed an ASProgressPopUpView inside a UITableViewCell the popUpView will probably be obscured by the cell above. The delegate method notifies you before the popUpView appears so that you can ensure that your UITableViewCell is rendered above the others.

The recommended technique for use with UITableView is to create a UITableViewCell subclass that implements the delegate method.

 @interface ProgressCell : UITableViewCell <ASProgressPopUpViewDelegate>
 @property (weak, nonatomic) IBOutlet ASProgressPopUpView *progressView;
 @end
 
 @implementation ProgressCell
 - (void)awakeFromNib
 {
    self.progressView.delegate = self;
 }
 
 - (void)progressViewWillDisplayPopUpView:(ASProgressPopUpView *)progressView;
 {
    [self.superview bringSubviewToFront:self];
 }
 @end

asprogresspopupview's People

Contributors

alskipp avatar cytryn avatar

Watchers

James Cloos avatar Brian Nguyen 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.