Giter VIP home page Giter VIP logo

playbutton's Introduction

PlayButton

Version License Platform

Overview

This project serves two purposes:

  1. It's a button I might use in another open source project (a customizable media player) but you can use it in your projects as well, if you just want the animated button and not the entire player.

  2. I wanted to create an animation + secondary animation that is reversible through user interaction. WHAT? Okay, so the whole state transition is one keyframe animation, but I cannot just "reverse" the animation, because the secondary animation (animation caused by the movement of the right pause layer) behaves differently depending on the direction (this influences the bending of the line). Since the solution I came up with is not that perfect, which partly results from wrong timing functions, the reversble animation is under the develop branch and you can just check it out. I consider switching from the CADisplayLink approach to a custom layer property animation, where progress would range from 0.0 to 1.0 and when there is still an animation going on while hitting the button I would remove the animation and add the reverse animation with 1.0 - progress. That way I could avoid all the state tracking.

Try develop

If you want to see how the reversible animation works, take a look at the develop branch, or - if you just want to use it - paste this:

pod 'PlayButton', :git => 'https://github.com/fruitcoder/PlayButton.git', :commit => '7b287f7'

Demo

alt tag

Usage

import PlayButton

let playButton = PlayButton(origin: CGPoint(x: 100, y: 100), width: 30.0, initialAction: .Pause)
playButton.addTarget(self, action: #selector(tap), forControlEvents: .TouchUpInside)
view.addSubview(playButton)

Or just add a UIButton to your Storyboard and set the class to PlayButton

Example

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

Requirements

  • ARC
  • iOS8

Installation

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

use_frameworks!

target '<Your Target Name>' do
  pod 'PlayButton'
end

Then, run the following command:

$ pod install

Author

Alexander Türk, [email protected]

License

PlayButton is available under the MIT license. See the LICENSE file for more info.

playbutton's People

Contributors

fruitcoder avatar

Stargazers

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