Latest 0.1.0
Homepage https://github.com/fruitcoder/PlayButton
License MIT
Platforms ios 8.0
Authors

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 Hüllmandel, [email protected]

License

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

Latest podspec

{
    "name": "PlayButton",
    "version": "0.1.0",
    "summary": "A subclass on UIButton that animates its state between a playing and a paused state.",
    "description": "This CocoaPod is a small part of a feature upcoming media player, that is currently under development and will be open sourced once its stable. Since the button itself can be used in other projects as a button that switches between play and pause, it makes sense to have it as a separate CocoaPod. The special thing about the animation is that the CAKeyframe animation reverses when the user touches the button during animation. Since this is still not working 100% it remains in a different branch and is open for testing.",
    "homepage": "https://github.com/fruitcoder/PlayButton",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Alexander Huu0308llmandel": "[email protected]"
    },
    "source": {
        "git": "https://github.com/fruitcoder/PlayButton.git",
        "tag": "0.1.0"
    },
    "social_media_url": "https://twitter.com/hllmandel",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "PlayButton/Classes/**/*"
}

Pin It on Pinterest

Share This