Coder Social home page Coder Social logo

snaptimer's Introduction

SnapTimer

SnapTimer

SnapTimer is a custom UIView that behaves exactly the same as the one on Snapchat's stories.

Build Status codecov.io

Features

  • Two different timers, 'outer' and 'inner'.
  • Independent animations for each of the timers.
  • Customizable colors.
  • Completion handlers.
  • Fully Swift.

What does it look like?

A picture is worth a thousand words

samples

Installation

You can just clone the repo and copy the SnapTimer folder to your project or you can use one of the following options:

Setting up with CocoaPods

pod 'SnapTimer'

Then:

import SnapTimer

And you are all set!

Setting up with Carthage

  • TODO

How do I add it?

  1. Add a UIView to your Storyboard.

  2. Select the view, go to the Identity Inspector and set the class to SnapTimerView

    identity-inspector

  3. Create an @IBOutlet in your view controller and that's it.

    SnapTimerView implements @IBDesignable so the view should automatically render in your Interface Builder. Also it implements @IBInspectable for the view properties:

    properties

  4. That's it!

Setting inner and outer values

innerValue and outerValue ranges go from 0 to 100.

  • To set values without animations you just have to:

self.snapTimerView.outerValue = 25 self.snapTimerView.innerValue = 50

   ![ej1](images/ej1.gif)

* To animate values:

    ```swift
self.snapTimerView.animateOuterValue(50)
self.snapTimerView.animateInnerValue(25)

ej1

  • To animate values setting the time and a completion handler:

    self.snapTimerView.animateOuterToValue(50, duration: 30) {
        puts("Done!")
    }
    
    self.snapTimerView.animateInnerToValue(100, duration: 30) {
        puts("Done!")
    }

Pausing and resuming animations:

if your app goes to background or the Notifications/Control center are opened you may want to pause the animations, to do that SnapTimer has two handy methods:

self.snapTimerView.resumeAnimation()
self.snapTimerView.pauseAnimation()

Check the sample project!

samples

Cool ways to improve it?

Hey, If you have cool ideas to add to this please feel free to send a PR! Also if you are using this in your app and what to let me know I'll be happy to add a section here with the apps currently using this!

Todo

  • Swift 2.3 and 3 ๐Ÿ‘Œ

snaptimer's People

Contributors

andresinaka avatar

Watchers

Chew Chit Siang avatar James Cloos 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.