Giter Club home page Giter Club logo

kdgoalbar's Introduction

This control was born out of the heady days of iOS 5 & 6. Needless to say, the iOS and design communities have moved on. Similar, better controls can be found here.

I'm leaving the files available because I believe there is something to be learned from every piece of code, even the bad ones that make tons of mistakes (Did I really use an NSTimer for an animation?! I'm sorry! I didn't know any better!)

KDGoalBar

Simple circular progress bar & bar chart.

The project comes with a fully functional example using Storyboards.

To add a Progress Bar programatically to an existing view, the following code assumes you are drawing the progress bars on the main view of your root view controller, which is called ViewController.

First, make sure to add all the required files:

  • SoundPlayer.(h/m)
  • KDBarGraph.(h/m)
  • KDGoalBar.(h/m)
  • KDGoalBarPercentLayer.(h/m)
  • All PNG files contained in the "images" folder

The following frameworks are also required:

  • QuartzCore
  • AudioToolbox
  • CoreGraphics

Your header file, ViewController.h:

#import <UIKit/UIKit.h>
#import "KDGoalBar.h"

@interface ViewController : UIViewController {
    KDGoalBar *percentGoalBar;
    KDGoalBar *thumbGoalBar;
}

@end

Your implementation file, should look like this:

#import "ViewController.h"

@implementation ViewController

- (void)viewDidLoad
{
    // Frame coordinates are arbitrary to make this code example shorter
    // You could use "self.view.frame.size" to place them in the right position
    CGRect goalBarFrame = CGRectMake(80, 10, 177, 177);
    KDGoalBar *gb = [[KDGoalBar alloc] initWithFrame:goalBarFrame];
    percentGoalBar = gb;
    [percentGoalBar setAllowDragging:YES];
    [percentGoalBar setAllowSwitching:NO];
    [percentGoalBar setPercent:74 animated:YES];
    [self.view addSubview:percentGoalBar];
    
    goalBarFrame = CGRectMake(80, 210, 177, 177);
    gb = [[KDGoalBar alloc] initWithFrame:goalBarFrame];
    thumbGoalBar = gb;
    [thumbGoalBar setThumbEnabled:YES];
    [thumbGoalBar setAllowSwitching:NO];
    [self.view addSubview:thumbGoalBar];
}


- (void)viewDidUnload
{
    percentGoalBar = nil;
    thumbGoalBar = nil;
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

@end

kdgoalbar's People

Watchers

 avatar  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.