Coder Social home page Coder Social logo

ttcounterlabel's Introduction

TTCounterLabel

A custom UILabel that acts as a time counter, counting up or down and formatting the string to hours, minutes, seconds and milliseconds. Designed to accept a value in milliseconds that is then displayed it in a time friendly format. Currently the controls supports up-to a maximum value of 99 hours 59 minutes 59 seconds and 999 milliseconds, which should be enough for most uses. The control automatically removes any leading zeros and centralises the result. It also supports different fonts for each unit division.

Alt text

Setup

Installing with CocoaPods

If you're unfamiliar with CocoaPods there is a great tutorial here to get you up to speed.

  1. In Terminal navigate to the root of your project.

  2. Run 'touch Podfile' to create the Podfile.

  3. Open the Podfile using 'open -e Podfile'

  4. Add the pod TTCounterLabel to your Podfile.

     platform :ios
     pod 'TTCounterLabel'
    
  5. Run pod install.

  6. Open your app's .xcworkspace file to launch Xcode and start using the control!

Installing manually from GitHub

  1. Download the TTCounterLabel.h and TTcounterLabel.m files and add them to your Xcode project.
  2. #import TTCounterLabel.h wherever you need it.
  3. Follow the included sample project to get started.

Running the sample project

Check out the sample project included in the repository. Just open the '.xcworkspace' file in the Sample folder and the project should build correctly.

Usage

  1. Add a normal Label control to your storyboard
  2. In the Identity Inspector for the label, set the Custom Class to TTCounterLabel
  3. Implement the TTCounterLabelDelegate interface to receive callbacks from the label
  4. Set the label's countDirection to one of kCountDirectionDown or kCountDirectionUp
  5. call [label setStartValue:<time in ms>] to set the start value (important in the case of a downward counter).
  6. Use [label start] and [label stop] to start and stop the counter.
  7. The counter calls back on the contdownDidEnd method on the class that implements TTCounterLabelDelegate. The source parameter will be a reference to the label object that fired the event.

Author(s)

Triggertrap Limited

Ross Gibson

Valentin Kalchev

Licence

Distributed under the MIT License.

ttcounterlabel's People

Contributors

valentin-kalchev avatar ascorbic avatar peisong 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.