Skip to content

iOS animation playback button inspired by the playback button of YouTube for web.

License

Notifications You must be signed in to change notification settings

carabina/PlaybackButton

 
 

Repository files navigation

PlaybackButton

Platform Language License Issues

iOS animation playback button inspired by the playback button of YouTube for web.

sample

##Installation

####CocoaPods

pod 'PlaybackButton'

####Manually Add the PlaybackButton.swift file to your project.

##Usage

###Setup

Add import PlaybackButton in your file

In your app delegate:

@IBOutlet weak var playbackButton: PlaybackButton!

self.playbackButton.layer.cornerRadius = self.playbackButton.frame.size.height / 2
self.playbackButton.layer.borderWidth = 2.0
self.playbackButton.adjustMargin = 1


@IBAction func didTapPlaybackButton(sender: AnyObject) {
    if self.playbackButton.buttonState == .Playing {
        self.playbackButton.setButtonState(.Pausing, animated: true)
    } else if self.playbackButton.buttonState == .Pausing {
        self.playbackButton.setButtonState(.Playing, animated: true)
    }
}
var playbackButton: PlaybackButton!

self.playbackButton = PlaybackButton(frame: CGRect(x: 0, y:20, width: 100, height: 100 ))
self.playbackButton.contentEdgeInsets = UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8)
self.playbackButton.adjustMargin = 0
self.playbackButton.addTarget(self, action: "didTapPlaybackButton:", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(self.playbackButton)

func didTapPlaybackButton(sender: AnyObject) {
    if self.playbackButton.buttonState == .Playing {
        self.playbackButton.setButtonState(.Pausing, animated: true)
    } else if self.playbackButton.buttonState == .Pausing {
        self.playbackButton.setButtonState(.Playing, animated: true)
    }
}

Requirements

Requires Swift2.0 and iOS 8.0 and ARC.
If you want to use even iOS7.0, please to import the code directly.

Features

  • Highly customizable
  • Complete example

Contributing

Forks, patches and other feedback are welcome.

Creator

Yuji Hato Blog

License

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

About

iOS animation playback button inspired by the playback button of YouTube for web.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 96.7%
  • Ruby 3.3%