Implementation of Snapchat's stories timer.

Overview

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!

You might also like...
Schedule timing task in Swift using a fluent API. (A friendly alternative to Timer)
Schedule timing task in Swift using a fluent API. (A friendly alternative to Timer)

Schedule(简体中文) Schedule is a timing tasks scheduler written in Swift. It allows you run timing tasks with elegant and intuitive syntax. Features Elega

This project is a minimalistic Pomodoro timer for OS X written in Swift
This project is a minimalistic Pomodoro timer for OS X written in Swift

Minimalistic Pomodoro for OSX This project is a minimalistic Pomodoro timer for OS X written in Swift started by @bengsfort, and substantially enhance

The most perfect Swift Timer you'll ever need.

Timerable ⏰ The most perfect Swift Timer you'll ever need. A protocol-oriented Timer Factory with all the features you'll ever need. I wrote it in bot

Well-tested GCD Timer in Swift
Well-tested GCD Timer in Swift

GCDTimer Well tested Grand Central Dispatch (GCD) Timer in Swift. Checkout the test file. Usage Long running timer import GCDTimer class Demo { in

A timer that lets you know when your ramen is ready to eat!
A timer that lets you know when your ramen is ready to eat!

Dependencies Ramen Timer requires the following: Gifu SwiftySound On Xcode simply go to File Add Packages and input the names on the searchbar then

This is an open source app made to help home brewers brew their coffee by calculating the grams of water needed, and run a timer all in the same screen.
This is an open source app made to help home brewers brew their coffee by calculating the grams of water needed, and run a timer all in the same screen.

Ratios This is an open source app made to help home brewers brew their coffee by calculating the grams of water needed, and run a timer all in the sam

Swift image slideshow with circular scrolling, timer and full screen viewer
Swift image slideshow with circular scrolling, timer and full screen viewer

🖼 ImageSlideshow Customizable Swift image slideshow with circular scrolling, timer and full screen viewer 📱 Example To run the example project, clon

Egg timer app written in Swift
Egg timer app written in Swift

Egg Timer Our Goal This module will be a mix of tutorials and challenges. Most importantly, we want you to get comfortable with looking up how to do s

A simple Timer app for Mac
A simple Timer app for Mac

A simple Timer app for Mac

A handy class for iOS to use UILabel as a countdown timer or stopwatch just like in Apple Clock App.
A handy class for iOS to use UILabel as a countdown timer or stopwatch just like in Apple Clock App.

MZTimerLabel Purpose MZTimerLabel is a UILabel subclass, which is a handy way to use UILabel as a countdown timer or stopwatch just like that in Apple

Egg Timer app helps you to cook your egg in the way you want

Egg Timer Egg Timer app helps you to cook your egg in the way you want. You need to decide on how do you want to eat your egg than just click the egg

THORChain vault churn countdown timer for macOS tray
THORChain vault churn countdown timer for macOS tray

ChurnCountdown Useful macOS tray app to show THORChain churn countdown. On start

A basic countdown app that allows the user to create, edit, and delete events. Each event contains a live countdown timer to a specified date and time.

Event Countdown App (iOS) Created by Lucas Ausberger About This Project Created: January 4, 2021 Last Updated: January 8, 2021 Current Verison: 1.1.1

Chess Timer - Time calculation application developed for chess game
Chess Timer - Time calculation application developed for chess game

Chess Timer Satranç oyunu için geliştirilmiş süre hesaplama uygulaması

Egg-Timer - Intermediate Swift Programming - Control Flow and Optionals

Egg-Timer Intermediate Swift Programming - Control Flow and Optionals What I lea

OpenFocusTimer - Pomodoro timer with categories, reflection, history & statistics

OpenFocusTimer Pomodoro timer with categories, reflection, history & statistics.

I have build a beautiful egg timer app to boil your eggs to perfection depending on how you prefer your eggs.
I have build a beautiful egg timer app to boil your eggs to perfection depending on how you prefer your eggs.

I build this app when taking course in Udemy. The course is "iOS & Swift - The Complete iOS App Development Bootcamp".

IdleTimerState - Control the idle timer for the SwiftUI app

IdleTimerState Control the idle timer for the SwiftUI app. import SwiftUI import

Spin aims to provide a versatile Feedback Loop implementation working with the three main reactive frameworks available in the Swift community (RxSwift, ReactiveSwift and Combine)
Spin aims to provide a versatile Feedback Loop implementation working with the three main reactive frameworks available in the Swift community (RxSwift, ReactiveSwift and Combine)

With the introduction of Combine and SwiftUI, we will face some transition periods in our code base. Our applications will use both Combine and a thir

Comments
  • Can't Clear when Preparing For Reuse

    Can't Clear when Preparing For Reuse

    I'm experiencing a bug where I have a couple timers in UITableViewCells and when scrolling sometimes the timers are set to the of another cell.

    Ex: cell one: timer is at 30% ^ | | v cell two timer is supposed to be at 100% but displays at 30%

    I've tried to put self.timer.animateOuterValue(0) in prepare for reuse but it didn't help

    Thanks, Kevin

    opened by ThoseGuysInTown 0
  • Animating timer with Duration does not work unless on main thread

    Animating timer with Duration does not work unless on main thread

    @andresinaka When animating the timer with duration, it doesnt work unless run on the mainthread like so...perhaps this should be done in the timer object otherwise you will be left wondering why it doesnt work.

    DispatchQueue.main.async {
                snapTimer.animateOuterToValue(100, duration: 100, completion: nil)
            }
    opened by otymartin 0
  • Cant access Timer properties

    Cant access Timer properties

    @andresinaka The color properties are inaccessible apparently because of internal access controls.

    let snapTimer = SnapTimerView(x: 0, y: 0, w: 24, h: 24) //How I initialize. Im not using storyboards
    opened by otymartin 0
Owner
Andres Canal
Andres Canal
Plugin-spell-timer - Spell Timer Plugin for Outlander

Spell Timer Plugin for Outlander This plugin provides variables for spells from

Outlander 0 Jan 22, 2022
IGStoryButtonKit provides an easy-to-use button with rich animation and multiple way inspired by instagram story/stories.

Introduction Have you ever seen UI like instagram story, haven't you? Actually, features like instagram story have been implemented in many applicatio

mutation 34 Nov 8, 2022
Snapchat / Instagram Stories like progress indicator

SegmentedProgressBar A simple little control that animates segments like Snapchat or Instagram Stories. Requirements iOS 8.0+ Xcode 8 Installation Dra

Dylan Marriott 442 Dec 25, 2022
iOS App to show Top Stories from New York Times

NYT News iOS app displaying New York Times top stories. Features Shows articles from various sections of New York Times top stories. Open each article

Muhammad Yusuf 1 Jan 14, 2022
Mybook swiftui - A Facebook UI Clone with some capabilities like like/unlike, comment, scroll, show stories etc

mybook_swiftui ?? Trying to create a Facebook UI Clone with some capabilities li

mogolAyberk 1 Apr 16, 2022
Simple command line interactive game to practice German (or English) with simple short stories.

Gif With GIF you can practice German or English with short stories. The stories are written in an easy language, and you can interact with the charact

Pedro Muniz 8 Nov 3, 2022
Swift UI component - Stories instagram, slideshow, crypto wallet intro

SwiftUI and Combine - Stories intro multi-platform widget Features Long tap - pause stories showcase Tap - next story Leeway - pause before start stor

Igor 9 Dec 26, 2022
GCDTimer - Well tested Grand Central Dispatch (GCD) Timer in Swift

GCDTimer Well tested Grand Central Dispatch (GCD) Timer in Swift. Checkout the test file. Usage Long running timer import GCDTimer

Hemant Sapkota 183 Sep 9, 2022
Schedule timing task in Swift using a fluent API. (A friendly alternative to Timer)

Schedule(简体中文) Schedule is a timing tasks scheduler written in Swift. It allows you run timing tasks with elegant and intuitive syntax. Features Elega

Luo Xiu 1.8k Jan 7, 2023
This Control is a beautiful time-of-day picker heavily inspired by the iOS 10 "Bedtime" timer.

#10Clock Dark and Mysterious ?? Light Colors ?? Usage The control itsself is TenClock. Add that to your view hierarchy, and constrain it to be square

Joe 557 Dec 23, 2022