Skip to content
프로젝트

소개

Implementation of Snapchat's stories timer.

디자인 및 미디어

이 수치를 측정하는 방법

What you can do

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

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
-1
in 1 month
업데이트 지연

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

SnapTimer

SnapTimer

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

Build Status codecov.io

Swift 3.0 Support on master branch! 👌👌 
Swift 2.3 Support on Swift2.3.

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!

관련 프로젝트 살펴보기

불러오는 중…