PlayButton

1.0.0

An animated play button written in Swift
public-value-tech/play-button

What's New

1.0.0

2022-02-22T16:19:52Z

Initial Release

PlayButton

A button that can render four different playback related modes and animate between them.

Different play button appearances

Installation (Swift Package Manager)

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding PlayButton as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
  .package(url: "https://github.com/public-value-tech/play-button.git", .branch("main"))
]

Usage

import PlayButton

let playButton = PlayButton() // defaults to CGSize(width: 44, height: 44)
playButton.playBufferingBackgroundColor = .systemBlue
playButton.pauseStopBackgroundColor = .systemBlue
playButton.playBufferingTintColor = .white
playButon.pauseStopTintColor = .white

// Animate the mode update
playButton.setMode(.stop, animated: true)

// iOS / macCatalyst 
playButton.addTarget(self, action: #selector(playButtonTapped), for: .touchUpInside))

// tvOS
playButton.addTarget(self, action: #selector(playButtonTapped), for: .primaryActionTriggered)

Documentation

Check out the documentation or just compile it yourself when you add the package to your projects. The documentation is created using the current versions of swift-docc and swift-docc-render to create a static website served via GitHub Pages. Once Swift 5.6 is released we can hopefully use transform-for-static-hosting on the docc compiler directly. If the folks at Swift Package Index decide to host the documentation directly, we will add support for this package as well if necessary.

Tests

The tests mostly consist of snapshot tests. We use a CADisplayLink to sample some frames from the animation and diff them against reference snapshots. Since there is some expected deviation we add some tolerance to the tests.

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

Last updated: Wed Sep 21 2022 21:24:33 GMT-0500 (GMT-05:00)