Code Monkey home page Code Monkey logo

sacountinglabel's Introduction

SACountingLabel

language CI Status Version License Platform

SACountingLabel is a highly customizable animated UILabel that can count, inspired by Tim Gostony's UICountingLabel. Originally created as an animated UI component for a game to display scores, SACountingLabel supports the use of various formats such as percentages, currencies and multiple decimal places. It can also be modified to use different animation modes such as linear, ease in, ease out as well as ease in and out.

int

float

custom

Installation

SACountingLabel is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "SACountingLabel"

And then run:

$ pod install

Manual Installation

To manually install SACountingLabel, simply add SACountingLabel.swift to your project.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

Creating a SACountingLabel is the same as creating a UILabel:

let label = SACountingLabel(frame: CGRect(x: 0, y: 0, width: 100, height: 50))

Or add it to your storyboard or XIB file and set the class type to SACountingLabel instead of UILabel.

This is the general syntax for counting from a start value to an end value for a specified counting and animation style.

label.countFrom(0, to: 100, withDuration: 1.0, andAnimationType: .EaseIn, andCountingType: .Int)

Start Value

The start value is a float value that the counting begins from.

End Value

The end value is a float value where the counting ends.

Duration

The duration is a float value for the length of the animation in seconds.

Animation Type

There are four animation types - linear, ease in, ease out, as well as ease in and ease out.

.Linear

Counts from the start value to the end value at a constant speed.

linear

.EaseIn

Starts counting from the start value slowly and speeds up as it approaches the end value.

easein

.EaseOut

Starts counting from the start value quickly and slows down as it approaches the end value.

easeout

.EaseInOut

Starts counting from the start value slowly, speeds up towards the middle, and slows down again as it approaches the end value.

easeinout

Counting Type

There are three counting types - integer, floating point and custom.

.Int

This will result in counting by integers. 0, 1, 2,..., 100

.Float

This will result in counting using floating points, with a default of 2 decimal places. 0.00, 0.01, 0.02,..., 100

.Custom

This allows you to specify a custom format for the counting. You will have to set the format like this:

label.format = "%.1f%%"

This will result in 0.0%, 0.1%, 0.2%,..., 100%.

Formats like "$%.2f" and "%i points" can be used as well.

License

Copyright (c) 2015 Sudeep Agarwal and Tim Gostony

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

sacountinglabel's People

Contributors

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sacountinglabel's Issues

Unknown class SACountingLabel in Interface Builder file

I added the pod, and am able to change the UILabel class to the SACountingLabel class in interface builder. I am also importing SACountingLabel. However, when I build and run the app, I get this error : Unknown class SACountingLabel in Interface Builder file

I am on xcode 7.3 , Swift 2.2

Thanks for any help

Build error with Xcode 7.3 (Swift 2.2)

Hi, I got an error when building with Xcode 7.3 (Swift 2.2):
CpResource /Volumes/Transcend/Xcode/DerivedData/Climendo-gwbfrdvyaiinfgdwbfajnrnwxfgz/Build/Products/Debug-iphoneos/SACountingLabel/SACountingLabel.bundle /Volumes/Transcend/Xcode/DerivedData/Climendo-gwbfrdvyaiinfgdwbfajnrnwxfgz/Build/Products/Debug-iphoneos/SACountingLabel/SACountingLabel.framework/SACountingLabel.bundle cd /Users/klwoon/Documents/projects/climendo/work/iOS/Climendo/Pods export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks /Volumes/Transcend/Xcode/DerivedData/Climendo-gwbfrdvyaiinfgdwbfajnrnwxfgz/Build/Products/Debug-iphoneos/SACountingLabel/SACountingLabel.bundle /Volumes/Transcend/Xcode/DerivedData/Climendo-gwbfrdvyaiinfgdwbfajnrnwxfgz/Build/Products/Debug-iphoneos/SACountingLabel/SACountingLabel.framework

error: /Volumes/Transcend/Xcode/DerivedData/Climendo-gwbfrdvyaiinfgdwbfajnrnwxfgz/Build/Products/Debug-iphoneos/SACountingLabel/SACountingLabel.bundle: No such file or directory

Could you please help to take a look? Thank you.

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.